-
Notifications
You must be signed in to change notification settings - Fork 189
Allocate enough space for Unicode strings in binary property lists. #148
Conversation
This seems right and it makes parsing get (much) further, but I don't know this code that well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok getting this in to unblock William, but we really need to start writing unit tests.
@grp, can you follow this up with a test? Merging a test binary plist with some emojis in it and making we can parse out expected values seems good enough for now.
@@ -176,7 +176,7 @@ Create(void *opaque, ABPRecordType type, void *arg1, void *arg2, void *arg3) | |||
if (ReadSeek(opaque, offset, SEEK_SET) < 0) | |||
return nullptr; | |||
|
|||
string.resize(nchars); | |||
string.resize(sizeof(char) * nchars); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: both here and for UTF16, use something like 'size_t stringsize = sizeof(foo) * nchar'
I'll add a test, although I'm not sure how to check anything except that it doesn't violate ASAN. With #131 that should be enough though. |
Before, only half as much space as needed was allocated.
Test added. Turns out it didn't decode the right string before either so the test did fail before the fix. |
Lgtm |
Sorry, finger slipped in mobile ui. Merge at your leisure. |
Before, only half as much space as needed was allocated. Fixes #145.