[plist] Always calc string length

Making the string length calc based on !json was a mistake that resulted
in running off the end of the dstring.
This commit is contained in:
Bill Currie 2025-01-04 23:21:04 +09:00
parent 400486931f
commit c0004ed7d5

View file

@ -1334,12 +1334,10 @@ write_string (dstring_t *dstr, const char *str, bool json)
char *dst;
bool quoted = json;
if (!quoted) {
for (s = str; *s; s++) {
if (is_quotable (*s))
quoted = true;
len++;
}
for (s = str; *s; s++) {
if (is_quotable (*s))
quoted = true;
len++;
}
if (!quoted) {
dst = dstring_openstr (dstr, len);