Merge pull request #1818 from muhmuhten/free_in_index

This commit is contained in:
Nico Williams authored and GitHub committed 2019-02-09 16:32:20 -06:00
commit 9fa2e51099
1 file changed
+6 -6
+6 -6
View File
@@ -658,12 +658,12 @@ jv jv_string_indexes(jv j, jv k) {
int idxlen = jv_string_length_bytes(jv_copy(k)); int idxlen = jv_string_length_bytes(jv_copy(k));
jv a = jv_array(); jv a = jv_array();
if (idxlen == 0) if (idxlen != 0) {
return a; p = jstr;
p = jstr; while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) {
while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) { a = jv_array_append(a, jv_number(p - jstr));
a = jv_array_append(a, jv_number(p - jstr)); p += idxlen;
p += idxlen; }
} }
jv_free(j); jv_free(j);
jv_free(k); jv_free(k);