Closed Bug 911806 Opened 11 years ago Closed 11 years ago

CompileError should implement operator=

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: billm, Assigned: Benjamin)

Details

Attachments

(1 file)

It has some fields that are malloced, and that get freed in the destructor. Therefore it needs an operator=. This came up in bug 911204.
Ooo, that's nasty. Brian's solution of bug 911204 seems good to be. Maybe it's better to just delete the copy-operator footguns.
Attachment #798575 - Flags: review?(wmccloskey)
Comment on attachment 798575 [details] [diff] [review]
remove copy and assignment operators of CompileError

Review of attachment 798575 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks.

::: js/src/frontend/TokenStream.h
@@ +319,5 @@
>      void throwError(JSContext *cx);
> +
> +    // CompileError owns raw allocated memory, so disable assignment and copying
> +    // for safety.
> +    void operator=(const CompileError &) MOZ_DELETE;

I'm not sure how important it is, but usually we make these private.
Attachment #798575 - Flags: review?(wmccloskey) → review+
private isn't strictly necessary, rather it's belt-and-suspenders.  If the compiler doesn't support = delete, then an access-check failure is a further backstop, and one that happens earlier than link failure from using an undefined function.  It doesn't catch users that are friends of the method, to be sure, but it's better than nothing for users with older compilers (actually only MSVC, now, I hear).
https://hg.mozilla.org/mozilla-central/rev/1604454f8d21
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: