Closed
Bug 14286
Opened 25 years ago
Closed 25 years ago
PL_HashString() with CRASH if key is NULL
Categories
(NSPR :: NSPR, defect, P3)
Tracking
(Not tracked)
RESOLVED
INVALID
People
(Reporter: sspitzer, Assigned: srinivas)
Details
(Keywords: crash)
PL_HashString(const void *key) will crash if it is passed NULL. see bug #14285 to see when this happens.
Reporter | ||
Comment 2•25 years ago
|
||
the bug is you need to add a null check to PL_HashString() so it won't crash if someone passes it a null.
Comment 3•25 years ago
|
||
In mozilla/nsprpub/lib/ds/plhash.h, we have: typedef PRUint32 PLHashNumber; PR_EXTERN(PLHashNumber) PL_HashString(const void *key); Since PLHashNumber is unsigned, it isn't clear what PL_HashString should return if someone passes it a null. A null is an invalid argument. The unsigned return type of PLHashNumber makes it impossible to return a failure status. This is similar to the string functions in <string.h>. It is not specified what these functions should return when they are passed (invalid) null arguments.
That is exactly the point; it is not possible to return a BAD_ARGUMENT error. If anything, an assert statement should be added to check for null pointers.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•