Closed Bug 1372555 Opened 8 years ago Closed 7 years ago

Fix some memory leaks found by infer

Categories

(NSPR :: NSPR, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

Details

Attachments

(1 obsolete file)

pr/src/io/pripv6.c:163: error: MEMORY_LEAK memory dynamically allocated to `newstack` by call to `PR_Malloc()` at line 144, column 16 is not reachable after line 163, column 5 161. _PR_ConvertToIpv6NetAddr(&tmp_ipv4addr, addr); 162. 163. > rv = PR_PushIOLayer(newfd, PR_TOP_IO_LAYER, newstack); 164. PR_ASSERT(PR_SUCCESS == rv); 165. return newfd; /* that's it */ pr/src/io/pripv6.c:199: error: MEMORY_LEAK memory dynamically allocated to `newstack` by call to `PR_Malloc()` at line 180, column 16 is not reachable after line 199, column 5 197. 198. /* this PR_PushIOLayer call cannot fail */ 199. > rv = PR_PushIOLayer(*nd, PR_TOP_IO_LAYER, newstack); 200. PR_ASSERT(PR_SUCCESS == rv); 201. return nbytes;
Attached patch doof.diff (obsolete) — Splinter Review
Attachment #8877116 - Flags: review?(kaie)
We should doublecheck if your patch is correct, or if your tool reported a false leak. Reading this documentation here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_PushIOLayer "The ownership of the storage pointed to by the caller's layer argument is relinquished to the runtime. Accessing the object via the pointer is not permitted while the runtime has ownership." It seems that ownership of the "newstack" parameter is transferred to NSPR.
Sylvestre, what's your opinion after comment 2?
Flags: needinfo?(sledru)
You are probably correct. I need to follow up with infer's upstream to make sure how to avoid that in the future :)
Comment on attachment 8877116 [details] [diff] [review] doof.diff marking as obsolete based on your agreement
Attachment #8877116 - Attachment is obsolete: true
Attachment #8877116 - Flags: review?(kaie)
Flags: needinfo?(sledru)

No action for a while, closing.

Status: NEW → RESOLVED
Closed: 7 years ago
QA Contact: jjones
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: