Skip to content

Commit

Permalink
Fix memory leak for { $foo: bar }
Browse files Browse the repository at this point in the history
{ BINDING: ExpD } wasn't freeing BINDING.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60865
  • Loading branch information
emanuele6 authored and nicowilliams committed Jul 28, 2023
1 parent 5b9d075 commit 17889a1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
35 changes: 18 additions & 17 deletions src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ IDENT ':' ExpD {
| BINDING ':' ExpD {
$$ = gen_dictpair(gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1))),
$3);
jv_free($1);
}
| BINDING {
$$ = gen_dictpair(gen_const($1),
Expand Down
6 changes: 5 additions & 1 deletion tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -1849,12 +1849,16 @@ reduce .[] as $then (4 as $else | $else; . as $elif | . + $then * $elif)
[10,19,27,34]


# { $__loc__ } works
# Object construction

{ a, $__loc__, c }
{"a":[1,2,3],"b":"foo","c":{"hi":"hey"}}
{"a":[1,2,3],"__loc__":{"file":"<top-level>","line":1},"c":{"hi":"hey"}}

1 as $x | "2" as $y | "3" as $z | { $x, as, $y: 4, ($z): 5, if: 6, foo: 7 }
{"as":8}
{"x":1,"as":8,"2":4,"3":5,"if":6,"foo":7}


# nan is parsed as a valid NaN value from JSON

Expand Down

0 comments on commit 17889a1

Please sign in to comment.