mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Fix a bug introduced by r9495 in which we try to write temporary NULs
into a string which is usually a read-only string literal. Instead, copy each segment into writable memory as we need it, and free it afterwards. [originally from svn r9558] [r9495 == d0ff371b144d4bfe3cbfb062388347c08e431393]
This commit is contained in:
11
osx.m
11
osx.m
@ -1088,15 +1088,16 @@ struct frontend {
|
||||
p = i->sval;
|
||||
c = *p++;
|
||||
while (*p) {
|
||||
char cc, *q;
|
||||
char *q, *copy;
|
||||
|
||||
q = p;
|
||||
while (*p && *p != c) p++;
|
||||
|
||||
cc = *p;
|
||||
*p = '\0';
|
||||
[pb addItemWithTitle:[NSString stringWithUTF8String:q]];
|
||||
*p = cc;
|
||||
copy = snewn((p-q) + 1, char);
|
||||
memcpy(copy, q, p-q);
|
||||
copy[p-q] = '\0';
|
||||
[pb addItemWithTitle:[NSString stringWithUTF8String:copy]];
|
||||
sfree(copy);
|
||||
|
||||
if (*p) p++;
|
||||
}
|
||||
|
Reference in New Issue
Block a user