Closed Bug 71283 Opened 25 years ago Closed 25 years ago

nsEventListenerManager::AddEventListener crashes if passed null listener

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla0.9

People

(Reporter: alex, Assigned: joki)

References

()

Details

Attachments

(1 file)

... because of a missing null-pointer check. Same for RemoveEventListener. Trival fix: Index: nsEventListenerManager.cpp =================================================================== RCS file: /cvsroot/mozilla/content/events/src/nsEventListenerManager.cpp,v retrieving revision 1.87 diff -c -7 -r1.87 nsEventListenerManager.cpp *** nsEventListenerManager.cpp 2001/01/23 03:10:25 1.87 --- nsEventListenerManager.cpp 2001/03/08 10:35:19 *************** *** 237,250 **** --- 237,252 ---- nsresult nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType) { nsVoidArray** listeners = GetListenersByIID(aIID); + if (nsnull == listeners) return NS_ERROR_FAILURE; + if (nsnull == *listeners) { *listeners = new nsVoidArray(); } if (nsnull == *listeners) { return NS_ERROR_OUT_OF_MEMORY; } *************** *** 314,327 **** --- 316,331 ---- nsresult nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener, const nsIID& aIID, PRInt32 aFlags, PRInt32 aSubType) { nsVoidArray** listeners = GetListenersByIID(aIID); + + if (nsnull == listeners) return NS_ERROR_FAILURE; if (nsnull == *listeners) { return NS_OK; } nsListenerStruct* ls; nsresult rv;
confirm bug to get on the radar
Status: UNCONFIRMED → NEW
Ever confirmed: true
Regarding the fix, you should return |NS_ERROR_NULL_POINTER| for nullpointers.
Surely you should return NS_ERROR_NULL_POINTER only if the function was actually passed a null pointer of sorts as an argument. NS_ERROR_INVALID_ARG is probably the right choice here?
Adding to 0.9 list. Will check in fix when tree opens.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9
Has this been checked in?
*** Bug 74732 has been marked as a duplicate of this bug. ***
Sorry, didn't check in patch alone as it got wrapped into a larger patch/rewrite of the surrounding code.
Create/Init/Dispatch bugs all fixed. Patches are attached to bug 25889.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Still crashing at http://www.protocol7.com/scroll/nsbug.html, Testcase from a duplicate bug #74732. (build 2001-04-19-04-trunk windows 98)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Okay, same function different crash. Close enough to be a dupe. I'll see if I can get a fix allowed in.
Status: REOPENED → ASSIGNED
Summary: nsEventListenerManager::AddEventListener crashes if passed unknown listener iid → nsEventListenerManager::AddEventListener crashes if passed null listener
[s]r=jst
Are you still shooting for 0.9 on this? If so please email drivers@mozilla.org with a status on you progress. If not please retarget against a later Milestone. Thanks.
Checked in with approval from choffmann from friday.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago25 years ago
Resolution: --- → FIXED
QA contact updated
QA Contact: gerardok → madhur
verified on build 2001-07-30-10-trunk
Status: RESOLVED → VERIFIED
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: