Closed Bug 568366 Opened 14 years ago Closed 14 years ago

IPDL: Allow copy-constructing and assigning from T__None-typed unions

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: cjones, Assigned: cjones)

References

Details

Attachments

(1 file)

A nasty little problem arises when we have unions buried within structs buried within unions buried within ...  When deserializing a union variable, we first read its type, then assign the union to the default-constructed value of that type (e.g., |u.get_Foo() = Foo();|), and finally deserialize a value of that type (|Read(msg, &u.get_Foo());|).  The problem is, if there are constituent union members buried within the Foo type, then the Foo default constructor will end up setting the union members to type T__None ("unassigned").  As it's currently considered to be an error to assign from an "unassigned" value, the call |u.get_Foo() = Foo();| will end up abort()ing.

The easiest way to fix this is to allow copy-constructing and assigning from "unassigned" unions, *but* still forbid them to be sent in IPC messages.
Assignee: nobody → jones.chris.g
Attachment #447639 - Flags: review?(mozilla+ben)
Comment on attachment 447639 [details] [diff] [review]
Patch and testcase

Makes sense to me.
Attachment #447639 - Flags: review?(mozilla+ben) → review+
http://hg.mozilla.org/mozilla-central/rev/192f6c0fbcce
Status: NEW → RESOLVED
Closed: 14 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: