Closed Bug 346083 Opened 18 years ago Closed 18 years ago

Crash [@ nsBoxObject::SetProperty] passing undefined to setProperty

Categories

(Core :: DOM: Core & HTML, defect)

PowerPC
macOS
defect
Not set
critical

Tracking

()

VERIFIED FIXED

People

(Reporter: jruderman, Assigned: smaug)

Details

(Keywords: crash, testcase)

Crash Data

Attachments

(4 files)

Passing undefined to boxObj.setProperty causes a crash [@ nsBoxObject::SetProperty].

This is similar to bug 327776, so the fix will probably be similar.
Attached file testcase
Attached patch proposed patchSplinter Review
I think removing property when undefined or null is used as value makes sense.
Assignee: general → Olli.Pettay
Status: NEW → ASSIGNED
Attachment #230885 - Flags: superreview?(bzbarsky)
Attachment #230885 - Flags: review?(bzbarsky)
Comment on attachment 230885 [details] [diff] [review]
proposed patch

I don't like the magic "read your mind" thing with removing.  Not only that, but that would make this inconsistent with SetPropertyAsSupports.

Why not just set to a null PRUnichar or to EmptyString.get() or something?
Attachment #230885 - Flags: superreview?(bzbarsky)
Attachment #230885 - Flags: superreview-
Attachment #230885 - Flags: review?(bzbarsky)
Attachment #230885 - Flags: review-
Null PRUnichar makes nsDependentString to crash and EmptyString.get() != null.
I want that if someone uses setProperty('foo', null)
getProperty('foo') returns null, not empty string.

But new patch coming.
or no (new patch). I'd have to change nsPresState::GetStateProperty too.
It returns NS_STATE_PROPERTY_NOT_THERE/null if the property is either null
or doesn't exist.
Last I checked, we wanted to stop using nsPresState here anyway.  If you can store null for now and just deal with the nsDependentString issue, we can fix the behavior when we don't use nsPresState, I guess...

roc may have opinions; he's looked at this code more than I recently.
This at least should do the right thing - storing null strings as properties.
(I should file a bug so that IsVoid flags is copied automatically when converting strings)
Attachment #230973 - Flags: superreview?(bzbarsky)
Attachment #230973 - Flags: review?(bzbarsky)
Comment on attachment 230973 [details] [diff] [review]
store null strings

>Index: layout/base/nsPresState.cpp
>+  nsCAutoString data = NS_ConvertUTF16toUTF8(aValue);
>+  data.SetIsVoid(aValue.IsVoid());

How about:

  NS_ConvertUTF16toUTF8 data(aValue);
  data.SetIsVoid(aValue.IsVoid());

Rest looks good.
Attachment #230973 - Flags: superreview?(bzbarsky)
Attachment #230973 - Flags: superreview+
Attachment #230973 - Flags: review?(bzbarsky)
Attachment #230973 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Verified FIXED using https://bugzilla.mozilla.org/attachment.cgi?id=230883&action=view as the testcase with build 2006-07-28-07 of SeaMonkey trunk under Windows XP; no crash.
Status: RESOLVED → VERIFIED
Crashtest checked in.
Flags: in-testsuite+
Crash Signature: [@ nsBoxObject::SetProperty]
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: