json: Fix memory leak when nesting depth is exceeded.
authorBen Pfaff <blp@nicira.com>
Mon, 1 Feb 2010 22:57:27 +0000 (14:57 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 2 Feb 2010 23:21:09 +0000 (15:21 -0800)
This is probably not an important memory leak, since it is only on a rare
error path, but it is best to fix it anyway.

Found with valgrind.

lib/json.c

index 0339a368d960268981810677f1f0d2bd913d197f..8fd9c3a7a5e488397bbc5ac0885373eda02ec367 100644 (file)
@@ -1213,6 +1213,7 @@ json_parser_push(struct json_parser *p,
         p->parse_state = new_state;
         return node;
     } else {
+        json_destroy(new_json);
         json_error(p, "input exceeds maximum nesting depth %d",
                    JSON_MAX_HEIGHT);
         return NULL;