json_quote_chararray: Always return a newly talloced array

The special case for len==0 was wrong---the normal code path is to
talloc to get a newly allocated, editable string, that might be
talloc_free'd later. It makes more sense just to let the len==0
behaviour fall through into the normal case code.

Reviewed-by: Carl Worth <cworth@cworth.org>
This results in the same value being returned, but with the proper
memory handling.
This commit is contained in:
Anthony 2010-04-20 08:55:31 -07:00 committed by Carl Worth
parent cacefbf3d6
commit 55d06f3e0b

3
json.c
View file

@ -57,9 +57,6 @@ json_quote_chararray(const void *ctx, const char *str, const size_t len)
size_t loop;
size_t required;
if (len == 0)
return (char *)"\"\"";
for (loop = 0, required = 0, ptr = str;
loop < len;
loop++, required++, ptr++) {