Closed
Bug 204623
Opened 22 years ago
Closed 22 years ago
[FIX]Setting src attribute on img element created in a doc with no window crashes [@ nsImgManager::GetRootDocShell]
Categories
(Core :: DOM: Core & HTML, defect, P1)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla1.4beta
People
(Reporter: peterv, Assigned: bzbarsky)
Details
(Keywords: crash, testcase, Whiteboard: TB19834763Q)
Crash Data
Attachments
(3 files)
505 bytes,
text/xml
|
Details | |
893 bytes,
patch
|
Details | Diff | Splinter Review | |
1.30 KB,
patch
|
mvl
:
review+
peterv
:
superreview+
asa
:
approval1.4+
|
Details | Diff | Splinter Review |
Setting the src attribute (through setAttributeNS) on an img element (created
with createElementNS) not part of a document crashes. This looks like a
regression from bug 83774. This also affects XSLT transforms that create
elements, since the XSLT processor adds attributes to the elements before adding
them to the tree.
Reporter | ||
Comment 1•22 years ago
|
||
Comment 2•22 years ago
|
||
Changing to all/all, also crashed on Windows 2000
Reporter | ||
Comment 3•22 years ago
|
||
Here's the relevant part of the stack:
#0 0x0cdb9488 in nsImgManager::GetRootDocShell(nsIDOMWindow*, nsIDocShell**)
#1 0x0cdb8850 in nsImgManager::ShouldLoad(int, nsIURI*, nsISupports*,
nsIDOMWindow*, int*)
#2 0x10051c28 in nsContentPolicy::CheckPolicy(int, int, nsIURI*,
nsISupports*, nsIDOMWindow*, int*)
#3 0x10051d50 in nsContentPolicy::ShouldLoad(int, nsIURI*, nsISupports*,
nsIDOMWindow*, int*)
#4 0x10553950 in NS_CheckContentLoadPolicy(int, nsIURI*, nsISupports*,
nsIDOMWindow*, int*)
#5 0x10114c84 in nsImageLoadingContent::CanLoadImage(nsIURI*, nsIDocument*)
#6 0x1011410c in nsImageLoadingContent::ImageURIChanged(nsACString const&)
#7 0x10113f1c in nsImageLoadingContent::ImageURIChanged(nsAString const&)
#8 0x10182de4 in nsHTMLImageElement::SetAttr(int, nsIAtom*, nsAString const&,
int)
#9 0x101495c4 in nsGenericHTMLElement::SetAttr(nsINodeInfo*, nsAString
const&, int)
#10 0x10182e50 in nsHTMLImageElement::SetAttr(nsINodeInfo*, nsAString const&, int)
#11 0x10093568 in nsGenericElement::SetAttributeNS(nsAString const&, nsAString
const&, nsAString const&)
#12 0x10603328 in nsHTMLImageElement::SetAttributeNS(nsAString const&,
nsAString const&, nsAString const&)
Reporter | ||
Comment 4•22 years ago
|
||
It crashes on
http://lxr.mozilla.org/seamonkey/source/extensions/cookie/nsImgManager.cpp#363
because aWindow is null.
![]() |
Assignee | |
Comment 5•22 years ago
|
||
Well.... that document indeed has no window associated with it. This is a
content policy bug -- it should null-check the window object it's passed, since
not all callers have a window object to give it (or better yet, we should take
dwitte's suggestion and eliminate the use of window objects in content policy
altogether).
This has come up before, and I fixed people to always create images in the right
document, but I forgot that we have this createDocument() business...
Summary: Setting src attribute on img element not in document crashes → Setting src attribute on img element created in a doc with no window crashes
![]() |
Assignee | |
Comment 6•22 years ago
|
||
So the question is: would one expect to be able to access useful things about
that image (such as its width and height) after creating the <img> node like
that? If so, we need to add a null-check to nsImgManager and have this open as
a privacy hole in mailnews (assuming someone has JS enabled in mailnews, of
course, in which case they're already screwed). If not, we could just not load
the image when we have no window object... (we do this "by hand" for XML loaded
as data in the XML content sink). But would that break XSLT?
Priority: -- → P1
Target Milestone: --- → mozilla1.4beta
Reporter | ||
Comment 7•22 years ago
|
||
Not sure, the case I was originally testing was transforming to a new document
and then setting that as the contentDocument of a bowser element. I never got to
verify whether that actually works, but if it does we need to load the images at
some point.
![]() |
Assignee | |
Comment 8•22 years ago
|
||
Ugh. Yeah, if you're doing that then we just need the null-check and we need to
implement dwitte's system ASAP.
Comment 9•22 years ago
|
||
The patch to nullcheck aWindow.
It is better to not rely too much on callers being nice :)
![]() |
Assignee | |
Comment 10•22 years ago
|
||
The CallQI change is not relevant to this bug but Had To Be Made.
![]() |
Assignee | |
Updated•22 years ago
|
Attachment #122596 -
Flags: superreview?(peterv)
Attachment #122596 -
Flags: review?(mvl)
![]() |
Assignee | |
Updated•22 years ago
|
Summary: Setting src attribute on img element created in a doc with no window crashes → [FIX]Setting src attribute on img element created in a doc with no window crashes
![]() |
Assignee | |
Comment 11•22 years ago
|
||
Eep. I totally missed mvl attaching a patch too. :) Well, r/sr=me on mvl's
patch if he prefers it to mine (mvl, you're basically the owner of this code as
far as I'm concerned, so what you say goes :) )
Comment 12•22 years ago
|
||
Comment on attachment 122596 [details] [diff] [review]
Simple fix by being a good nsCOMPtr citizen
Well, we submitted them at almost the same time :)
I prefer this, as the docs on xpcom tell to not use QueryInterface directly.
Attachment #122596 -
Flags: review?(mvl) → review+
Reporter | ||
Comment 13•22 years ago
|
||
Comment on attachment 122596 [details] [diff] [review]
Simple fix by being a good nsCOMPtr citizen
Thanks for the cleanup, my finger started itching when I saw that code :-).
Attachment #122596 -
Flags: superreview?(peterv) → superreview+
Comment 14•22 years ago
|
||
Comment on attachment 122596 [details] [diff] [review]
Simple fix by being a good nsCOMPtr citizen
requesting approval for 1.4b.
This is a simple fix for a crash, and is low-risk. This code is just following
the rules now.
Attachment #122596 -
Flags: approval1.4b?
Comment 15•22 years ago
|
||
Comment on attachment 122596 [details] [diff] [review]
Simple fix by being a good nsCOMPtr citizen
clicking over to approval1.4? since 1.4b's release is imminent.
Attachment #122596 -
Flags: approval1.4b? → approval1.4?
Comment 16•22 years ago
|
||
Yeah, I can see definite advantages with this magical fix bz refers to in
comment 8. However, note that it's not my idea, it was mvl's. I'm just pushing
it. :)
I'll throw together a small doc on it tomorrow. Maybe we can remove the
channel/docshell/whatever inparam from contentpolicy API's completely because of
this?
![]() |
Assignee | |
Comment 17•22 years ago
|
||
Well, we would like to keep the channel (for ShouldProcess, not ShouldLoad, I
would say). And we may want to keep an aContext that will be somehow usefully
defined, maybe. But we definitely do not want to pass in a nsIDOMWindow.
Comment 18•22 years ago
|
||
Comment on attachment 122596 [details] [diff] [review]
Simple fix by being a good nsCOMPtr citizen
a=asa (on behalf of drivers) for checkin to 1.4.
Attachment #122596 -
Flags: approval1.4? → approval1.4+
Comment 19•22 years ago
|
||
checked in to trunk.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Summary: [FIX]Setting src attribute on img element created in a doc with no window crashes → [FIX]Setting src attribute on img element created in a doc with no window crashes [@ nsImgManager::GetRootDocShell]
Updated•14 years ago
|
Crash Signature: [@ nsImgManager::GetRootDocShell]
You need to log in
before you can comment on or make changes to this bug.
Description
•