Closed Bug 345371 Opened 15 years ago Closed 15 years ago

Check before using weak pointer in nsCaret (Crash [@ nsCaret::DrawCaret])

Categories

(Core :: Layout, defect)

x86
All
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: sharparrow1, Assigned: sharparrow1)

References

Details

(Keywords: fixed1.8.1)

Attachments

(2 files, 2 obsolete files)

Talkback ID TB21175066W.  Not reproducable, but it's easy to guess what's causing the crash, and it really should get fixed in any case.  Using a weak
pointer without checking it's valid is a bad idea.

http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/layout/base/nsCaret.cpp&rev=1.160&mark=985-986#984

It's apparently rare; Talkback says there have been 62 crashes in nsCaret::DrawCaret since late March.

Easy patch coming up to fix all the unchecked uses of mPresShell.

Setting dependency on bug 305798 since that patch added the relevant code.
Attached patch PatchSplinter Review
Assignee: nobody → sharparrow1
Status: NEW → ASSIGNED
Attachment #230004 - Flags: review?(roc)
In my defense, there was already one use of the unchecked weak pointer (in GetCaretCoordinates) prior to my fix for bug 305798. I probably just copied that to the other places.

Anyway, thanks for finding this and providing a patch.
Checked in.
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment on attachment 230004 [details] [diff] [review]
Patch

Probably a good idea to get this on the branch.
Attachment #230004 - Flags: approval1.8.1?
Comment on attachment 230004 [details] [diff] [review]
Patch

a=darin on behalf of drivers
Attachment #230004 - Flags: approval1.8.1? → approval1.8.1+
Whiteboard: [checkin needed (1.8 branch)]
Attached patch patch for 1.8.1 branch (obsolete) — Splinter Review
Attachment #230357 - Attachment is obsolete: true
Attached patch patch for1.8.1 branch (obsolete) — Splinter Review
The trunk patch doesn't apply cleanly to the 1.8.1 branch. Someone should check if this patch is correct for the 1.8.1 branch, I think it is.
Ok, thanks, then I guess this is good to go in.
Attachment #230358 - Attachment is obsolete: true
Checking in nsCaret.cpp;
/cvsroot/mozilla/layout/base/nsCaret.cpp,v  <--  nsCaret.cpp
new revision: 1.144.2.9; previous revision: 1.144.2.8
done

Checked into 1.8.1 branch.
Whiteboard: [checkin needed (1.8 branch)]
Keywords: fixed1.8.1
Product: Core → Core Graveyard
Component: Layout: Misc Code → Layout
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.