Closed Bug 617693 Opened 15 years ago Closed 15 years ago

testURL/writeout use delete[] on nsMemory::Alloc o_Result and strdup(temp) when they don't leak

Categories

(Core :: Networking, defect)

defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla5

People

(Reporter: timeless, Assigned: timeless)

References

(Blocks 1 open bug)

Details

(Keywords: coverity)

Attachments

(1 file, 1 obsolete file)

ToNewCString uses nsMemory::Alloc, so the free side needs to be nsMemory::Free, not delete[] 71 nsresult writeoutto(const char* i_pURL, char** o_Result, PRInt32 urlFactory = URL_FACTORY_DEFAULT) 72 { 75 *o_Result = 0; 104 nsCString output; 105 if (NS_SUCCEEDED(result)) 106 { 151 *o_Result = ToNewCString(output); 152 } else { 154 *o_Result = ToNewCString(output); 155 } 156 return NS_OK; 157 } 159 nsresult writeout(const char* i_pURL, PRInt32 urlFactory = URL_FACTORY_DEFAULT) 160 { 161 char* temp = 0; 162 if (!i_pURL) return NS_ERROR_FAILURE; 163 int rv = writeoutto(i_pURL, &temp, urlFactory); 164 printf("%s\n%s\n", i_pURL, temp); 165 delete[] temp; 166 return rv; 167 } 171 nsresult testURL(const char* i_pURL, PRInt32 urlFactory = URL_FACTORY_DEFAULT) 193 while (fgets(temp,512,testfile)) 198 if (0 == count%3) 199 { 200 if (prevResult) delete[] prevResult; 202 writeoutto(temp, &prevResult, urlFactory); 232 } 233 if (failed>0) { leak prevResult: 235 return NS_ERROR_FAILURE; 236 } else { leak prevResult: 238 return NS_OK; 239 } 240 }
Attached patch CString (obsolete) — Splinter Review
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #496382 - Flags: review?(cbiesinger)
Attachment #496382 - Flags: approval2.0?
Comment on attachment 496382 [details] [diff] [review] CString actually, if (tempurl) delete[] tempurl; tempurl = strdup(temp); is also bad, new patch in a bit
Attachment #496382 - Attachment is obsolete: true
Attachment #496382 - Flags: review?(cbiesinger)
Attachment #496382 - Flags: approval2.0?
Summary: testURL/writeout use delete[] on nsMemory::Alloc o_Result when they don't leak → testURL/writeout use delete[] on nsMemory::Alloc o_Result and strdup(temp) when they don't leak
Attached patch bigger patchSplinter Review
Attachment #496617 - Flags: review?(cbiesinger)
Attachment #496617 - Flags: approval2.0?
Attachment #496617 - Flags: review?(cbiesinger) → review+
Comment on attachment 496617 [details] [diff] [review] bigger patch Mass minusing patch approval that don't have high return. Please renominate if this is more important for 2.0 than it appears.
Attachment #496617 - Flags: approval2.0? → approval2.0-
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-cedar
Target Milestone: --- → mozilla2.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: