Closed Bug 619813 Opened 14 years ago Closed 14 years ago

sftkdb_DeleteSecmodDB leaks block if fgets fails after continue

Categories

(NSS :: Libraries, defect)

x86
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: timeless, Assigned: timeless)

References

()

Details

(Keywords: coverity, memory-leak)

Attachments

(1 file, 1 obsolete file)

fwiw, colapses is misspelled

533 sftkdb_DeleteSecmodDB(SDBType dbType, const char *appName, 
542     char *block = NULL;
588     while (fgets(line, sizeof(line), fd) != NULL) { 
612             block = sftkdb_DupCat(block,line);
613             continue;

the code here assumes that after continue fgets will succeed again. this seems unlikely.
Attached patch proposal (obsolete) — Splinter Review
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #498300 - Flags: review?(nelson)
Comment on attachment 498300 [details] [diff] [review]
proposal

r=nelson
Attachment #498300 - Flags: review?(nelson) → review+
Comment on attachment 498300 [details] [diff] [review]
proposal

Thanks for the patch.  You just need to call
    PORT_Free(block);

PORT_Free does nothing if the input is NULL, and it's not
necessary to set 'block' to NULL because we're returning
from the function immediately.
Attached patch less thinkingSplinter Review
Attachment #498300 - Attachment is obsolete: true
Attachment #501647 - Flags: review+
Bug 619813: sftkdb_DeleteSecmodDB leaks block if fgets fails after continue
Patch contributed by Timeless <timeless@mozdev.org>, r=nelson

Checking in softoken/sftkmod.c; new revision: 1.8; previous revision: 1.7
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: