If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

CompileError should implement operator=

RESOLVED FIXED in mozilla26

Status

()

Core
JavaScript Engine
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: billm, Assigned: Benjamin)

Tracking

unspecified
mozilla26
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
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.
(Assignee)

Comment 1

4 years ago
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.
(Assignee)

Comment 2

4 years ago
Created attachment 798575 [details] [diff] [review]
remove copy and assignment operators of CompileError
Attachment #798575 - Flags: review?(wmccloskey)
(Reporter)

Comment 3

4 years ago
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+
(Assignee)

Comment 4

4 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/1604454f8d21
Assignee: general → benjamin
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).

Comment 6

4 years ago
https://hg.mozilla.org/mozilla-central/rev/1604454f8d21
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.