Fix infinite loop in index("") (fix #1815)

This commit is contained in:
Nicolas Williams committed 2019-02-08 20:40:55 -06:00
1 parent 18ac789d6d
commit 2660b04a73
2 files changed
+7

No files matched your search

+2
View File
@@ -658,6 +658,8 @@ jv jv_string_indexes(jv j, jv k) {
int idxlen = jv_string_length_bytes(jv_copy(k));
jv a = jv_array();
if (idxlen == 0)
return a;
p = jstr;
while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {
a = jv_array_append(a, jv_number(p - jstr));
+5
View File
@@ -1538,4 +1538,9 @@ isempty(1,error("foo"))
null
false
# Regression test for #1815
index("")
""
null