Commit 4588e6e2 authored by Thomas Van Lenten's avatar Thomas Van Lenten

Force a copy when saving the NSData that came from another.

parent 43caa38d
...@@ -2027,7 +2027,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) { ...@@ -2027,7 +2027,12 @@ static GPBUnknownFieldSet *GetOrMakeUnknownFields(GPBMessage *self) {
[newInput release]; [newInput release];
} else { } else {
GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self); GPBUnknownFieldSet *unknownFields = GetOrMakeUnknownFields(self);
[unknownFields mergeMessageSetMessage:typeId data:rawBytes]; // rawBytes was created via a NoCopy, so it can be reusing a
// subrange of another NSData that might go out of scope as things
// unwind, so a copy is needed to ensure what is saved in the
// unknown fields stays valid.
NSData *cloned = [NSData dataWithData:rawBytes];
[unknownFields mergeMessageSetMessage:typeId data:cloned];
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment