Merge pull request #231 from DRMacIver/fix_mem_leak_in_compile

args to jq_compile_args were not getting freed when there were errors in the compile
This commit is contained in:
Stephen Dolan committed 2013-12-08 15:17:20 -08:00
commit 4ba0c8baef
2 files changed
+8 -1

No files matched your search

+1 -1
View File
@@ -770,12 +770,12 @@ int jq_compile_args(jq_state *jq, const char* str, jv args) {
program = gen_var_binding(gen_const(value), jv_string_value(name), program);
jv_free(name);
}
jv_free(args);
nerrors = builtins_bind(jq, &program);
if (nerrors == 0) {
nerrors = block_compile(program, &locations, &jq->bc);
}
}
jv_free(args);
if (nerrors) {
jv s = jv_string_fmt("%d compile %s", nerrors,
nerrors > 1 ? "errors" : "error");
+7
View File
@@ -252,4 +252,11 @@ static void jv_test() {
jv_free(o2);
}
/// Compile errors
{
jq_state *jq = jq_init();
jq_compile_args(jq, "}", jv_array());
jq_teardown(&jq);
}
}