Closed Bug 344403 Opened 18 years ago Closed 18 years ago

Don't refer to |this| in accessible object constructors

Categories

(Core :: Disability Access APIs, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: aaronlev, Assigned: aaronlev)

References

Details

(Keywords: access)

Attachments

(1 file, 1 obsolete file)

It is dangerous to call any method which refers to |this|, because the vtbl is not fully constructed yet. Also the object isn't refcounted yet, so if using this causes it to get addrefed and released you will be destroyed during construction.

Bad practice. It can lead to crashes.
*** Bug 344402 has been marked as a duplicate of this bug. ***
Attachment #228986 - Flags: superreview?(neil)
Attachment #228986 - Flags: review?(neil)
+  accService->CreateHyperTextAccessible(captionNode, aCaption);
+  nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(*aCaption));
+  if (accessNode) {
+    accessNode->Init();
+  }
 }

You're falling off the edge without returning a value.
CreateHyperTextAccessible() sounds like it can fail?


+    nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(accHead));
+    accessNode->Init();

Missing "if (accessNode)" here?

Init() can fail?
Attachment #228986 - Attachment is obsolete: true
Attachment #229027 - Flags: review?(mats.palmgren)
Attachment #228986 - Flags: superreview?(neil)
Attachment #228986 - Flags: review?(neil)
Neil, I accidentally wrote sr=neil on the checkin comment. Sorry about that.

Mats, I think we're going to have to generally go through and check return values better in a code cleanup at some point.

Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: