From 55d06f3e0bc12c27879bba98153d70ea399ec737 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 20 Apr 2010 08:55:31 -0700 Subject: [PATCH] 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. --- json.c | 3 --- 1 file changed, 3 deletions(-) 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++) { -- 2.43.0