Closed Bug 812407 Opened 12 years ago Closed 12 years ago

nssutil_escapeQuotes adds 2 to the allocation size redundantly

Categories

(NSS :: Libraries, defect, P2)

3.14
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.14.1

People

(Reporter: wtc, Assigned: wtc)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
The function nssutil_escapeQuotes was added in the patch for bug 753116.

nssutil_escapeQuotes calls nssutil_escapeQuotesSize to calculate the allocation
size, but then it adds 2 to the allocation size. The 2 is apparently for the
addquotes=PR_TRUE case, but nssutil_escapeQuotesSize already adds 2 to the
allocation size in that case.
Attachment #682303 - Flags: review?(rrelyea)
This shows nssutil_escapeQuotesSize already adds 2 to the allocation size
if addquotes is PR_TRUE, so nssutil_escapeQuotes does not need to add 2
again:

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/security/nss/lib/util/utilpars.c&rev=1.3&mark=318,323,333,340,342#313

Looking at this more closely, I suspect the 2 may have been added to
compensate for bug 785208.
Comment on attachment 682303 [details] [diff] [review]
Patch

r+ I think so. Also it's an alloc, so it's safer to allocate more than less (I've been known to add fudge factors into allocates just so I don't get bit by off by one errors).

bob
Attachment #682303 - Flags: review?(rrelyea) → review+
Patch checked in on the NSS trunk (NSS 3.14.1).

Checking in utilpars.c;
/cvsroot/mozilla/security/nss/lib/util/utilpars.c,v  <--  utilpars.c
new revision: 1.5; previous revision: 1.4
done
Status: ASSIGNED → RESOLVED
Closed: 12 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: