From: Anthony Date: Tue, 20 Apr 2010 15:55:31 +0000 (-0700) Subject: json_quote_chararray: Always return a newly talloced array X-Git-Tag: 0.3~146 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=55d06f3e0bc12c27879bba98153d70ea399ec737;p=notmuch.git 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 This results in the same value being returned, but with the proper memory handling. --- diff --git a/json.c b/json.c index 3fd923ca..817fc83a 100644 --- a/json.c +++ b/json.c @@ -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++) {