Closed Bug 1167249 Opened 4 years ago Closed 4 years ago

ssltunnel.cpp:1321:9: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]

Categories

(Testing :: Mochitest, defect)

defect
Not set

Tracking

(firefox41 fixed)

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

New build warnings, when compiling mozilla-inbound with clang 3.7:
{
 5:25.78 Warning: -Wmismatched-new-delete in /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?
 5:25.78 /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp:1321:9: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
 5:25.78         delete hostname_copy;
 5:25.78         ^
 5:25.78               []
 5:25.78 /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp:1306:29: note: allocated with 'new[]' here
 5:25.78       char *hostname_copy = new char[strlen(hostname)+strlen(hostportstring)+2];
 5:25.78                             ^
 5:25.79 Warning: -Wmismatched-new-delete in /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'?
 5:25.79 /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp:1322:9: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
 5:25.79         delete redir_copy;
 5:25.79         ^
 5:25.79               []
 5:25.79 /scratch/work/builds/mozilla-inbound/mozilla/testing/mochitest/ssltunnel/ssltunnel.cpp:1316:26: note: allocated with 'new[]' here
 5:25.79       char *redir_copy = new char[strlen(redirhoststring)+1];
 5:25.79                          ^
}


Looks like these delete statements were introduced in
 https://hg.mozilla.org/integration/mozilla-inbound/rev/c4bab6f234f6
Ryan, would you mind taking this? I think we just need to convert these delete statements (for hostname_copy and redir_copy) to use "delete[]"?
Flags: needinfo?(nathmatics)
Actually, I'll just take this, since it's trivial and I'm not sure if other compilers warn about this clearly.
Assignee: nobody → dholbert
Flags: needinfo?(nathmatics)
Attached patch fix (obsolete) — Splinter Review
Attachment #8608809 - Flags: review?(ted)
Updated the fix to have more lines of context, so you can see the "new" statements that do the allocation for these variables. (to verify that it's really new[])
Attachment #8608809 - Attachment is obsolete: true
Attachment #8608809 - Flags: review?(ted)
Attachment #8608812 - Flags: review?(ted)
Daniel, looks like my compiler didn't pick this warning up. Sorry about that!
No worries -- delete/delete[] is an easy mistake to make (and I think it might only be a warning in newer compiler versions, maybe only clang 3.7).

(I also filed Bug 1167250 will make us treat build warnings in this directory as errors from now on, to make issues like this more likely to be caught.)
Attachment #8608812 - Flags: review?(ted) → review+
https://hg.mozilla.org/mozilla-central/rev/d4387922c102
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in before you can comment on or make changes to this bug.