SetOrRemoveObject doesn't check the return value of PL_DHashTableInit

RESOLVED FIXED

Status

()

Core
XBL
--
minor
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: timeless, Assigned: timeless)

Tracking

Trunk
x86
Windows 2000
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Assignee)

Description

15 years ago
This is a code inspection bug.

QA:
To verify that this bug is fixed, make sure that all callers in of 
PL_DHashTableInit in the indicated class/file check and handle a failure return 
result.
To verify that this bug is invalid, simply verify (e.g. with lxr) that 
PL_DHashTableInit is no longer used by the indicated class/file.

PL_DHashTableInit returns a PRBool indicating whether it succeeded. 
PL_DHashTableInit *can* fail. Code can not assume that table->ops or table-
>data will be null (in fact it probably will not be), although in all 
likelyhood table->entryStore will be null it probably isn't safe to assume this.

Code at time of bug filing:


 297 static nsresult
 298 SetOrRemoveObject(PLDHashTable& table, nsISupports* aKey, nsISupports* 
aValue)
 299 {
 300   // lazily create the table, but don't create it just to remove a
 301   // non-existent element!
 302   if (!table.ops && aValue)
 303     PL_DHashTableInit(&table, &ObjectTableOps, nsnull,
 304                       sizeof(ObjectEntry), 16);
 305
 306   if (aValue)
 307     return AddObjectEntry(table, aKey, aValue);
 308
 309   // no value, so remove the key from the table
 310   if (table.ops)
 311     RemoveObjectEntry(table, aKey);
 312   return NS_OK;
 313 }
(Assignee)

Comment 1

15 years ago
Created attachment 126840 [details] [diff] [review]
check
(Assignee)

Updated

15 years ago
Attachment #126840 - Flags: superreview?(dbaron)
Attachment #126840 - Flags: review?(alecf)
Comment on attachment 126840 [details] [diff] [review]
check

sr=dbaron, but why not move the whole thing into the |if (aValue)| below?
Attachment #126840 - Flags: superreview?(dbaron) → superreview+
(Assignee)

Comment 3

15 years ago
will do
Status: NEW → ASSIGNED

Comment 4

15 years ago
Comment on attachment 126840 [details] [diff] [review]
check

sr=alecf
Attachment #126840 - Flags: review?(alecf) → review+
(Assignee)

Comment 5

15 years ago
checked in
(Assignee)

Comment 6

15 years ago
checked in
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.