Fix assert fail when delpaths is given non-array (fix #901)

This commit is contained in:
David Tolnay committed 2015-08-16 19:44:16 -07:00
1 parent 2d05b5475c
commit b8f71d3659
2 files changed
+9

No files matched your search

+5
View File
@@ -390,6 +390,11 @@ static jv delpaths_sorted(jv object, jv paths, int start) {
}
jv jv_delpaths(jv object, jv paths) {
if (jv_get_kind(paths) != JV_KIND_ARRAY) {
jv_free(object);
jv_free(paths);
return jv_invalid_with_msg(jv_string("Paths must be specified as an array"));
}
paths = jv_sort(paths, jv_copy(paths));
jv_array_foreach(paths, i, elem) {
if (jv_get_kind(elem) != JV_KIND_ARRAY) {
+4
View File
@@ -756,6 +756,10 @@ delpaths([[-200]])
[1,2,3]
[1,2,3]
try delpaths(0) catch .
{}
"Paths must be specified as an array"
del(.), del(empty), del((.foo,.bar,.baz) | .[2,3,0]), del(.foo[0], .bar[0], .foo, .baz.bar[0].x)
{"foo": [0,1,2,3,4], "bar": [0,1]}
null