Closed Bug 39942 Opened 25 years ago Closed 25 years ago

PR_SetError calls free.

Categories

(NSPR :: NSPR, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wtc, Assigned: larryh)

Details

Attachments

(2 files)

PR_SetError always deletes the calling thread's errorString buffer. This may result in excessive calls to free. The errorString buffer should be kept around for possible reuse. PR_SetError just needs to mark the errorString buffer empty.
Status: NEW → ASSIGNED
Target Milestone: --- → 4.1
Reassigned to larryh.
Assignee: wtc → larryh
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Checked in parts: Checking in pr/include/private/primpl.h; /cvsroot/mozilla/nsprpub/pr/include/private/primpl.h,v <-- primpl.h new revision: 3.48; previous revision: 3.47 done Checking in pr/src/misc/prerror.c; /cvsroot/mozilla/nsprpub/pr/src/misc/prerror.c,v <-- prerror.c new revision: 3.7; previous revision: 3.6 done Checking in pr/tests/Makefile; /cvsroot/mozilla/nsprpub/pr/tests/Makefile,v <-- Makefile new revision: 3.62; previous revision: 3.61 done RCS file: /cvsroot/mozilla/nsprpub/pr/tests/errset.c,v done Checking in pr/tests/errset.c; /cvsroot/mozilla/nsprpub/pr/tests/errset.c,v <-- errset.c initial revision: 1.1 done
Larry, I reviewed your checkin. I like it that you are defining errorStringSize and errorStringLength as buffer size and string length, respectively. The original code defined errorStringSize as "buffer size - 1" (i.e., the string length), which was really confusing. I found two minor problems. One is that we need to set errorStringLength to 0 whenever we set errorStringSize to 0. The other is that in PR_GetErrorText(), errorStringSize needs to be changed to errorStringLength. I will attach a patch.
marking as fixed.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
I checked in my additional fixes (attachment id=10559). /cvsroot/mozilla/nsprpub/pr/src/misc/prerror.c, revision: 3.8 /cvsroot/mozilla/nsprpub/pr/src/threads/prcthr.c, revision: 3.17 /cvsroot/mozilla/nsprpub/pr/src/threads/combined/pruthr.c, revision: 3.29
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: