Closed Bug 228618 Opened 22 years ago Closed 22 years ago

nssPKIObject_RemoveInstanceForToken uses realloc incorrectly.

Categories

(NSS :: Libraries, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: wtc)

References

Details

Attachments

(1 file)

nssPKIObject_RemoveInstanceForToken uses realloc incorrectly. object->instances = nss_ZREALLOCARRAY(object->instances, nssCryptokiObject *, object->numInstances); if (!object->instances) { PZ_Unlock(object->lock); return PR_FAILURE; } There are two problems. 1. It would lose the pointer to the previously allocated memory block if realloc returns NULL. 2. We are using realloc to shrink the array here. Failure to shrink the array should be ignored.
Attached patch Proposed patchSplinter Review
This patches fixes the two problems described above. It also fixes an unused variable compiler warning.
Attachment #137500 - Flags: superreview?(MisterSSL)
Attachment #137500 - Flags: review?(jpierre)
Attachment #137500 - Flags: review?(jpierre) → review+
Fix checked in. Checking in pkibase.c; /cvsroot/mozilla/security/nss/lib/pki/pkibase.c,v <-- pkibase.c new revision: 1.22; previous revision: 1.21 done
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.9
Attachment #137500 - Flags: superreview?(MisterSSL) → superreview+
*** Bug 221128 has been marked as a duplicate of this bug. ***
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: