Fix infinite loop in index("") (fix #1815)
This commit is contained in:
1 parent
18ac789d6d
commit
2660b04a73
2 files changed
+7
No files matched your search
@@ -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));
|
||||
|
||||
@@ -1538,4 +1538,9 @@ isempty(1,error("foo"))
|
||||
null
|
||||
false
|
||||
|
||||
# Regression test for #1815
|
||||
index("")
|
||||
""
|
||||
null
|
||||
|
||||
|
||||
Reference in new issue
Block a user