diff options
author | Nico Williams <nico@cryptonector.com> | 2019-02-09 16:32:20 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-09 16:32:20 -0600 |
commit | 9fa2e51099c55af56e3e541dc4b399f11de74abe (patch) | |
tree | 0fc0322e726f9a6eb8637defbff27b28c316cce0 | |
parent | 88613f546926a7737af7542bf0a74a22d935cd14 (diff) | |
parent | 3f59bee3e080c4b1ee2ae94244ac0263a69999d2 (diff) |
Merge pull request #1818 from muhmuhten/free_in_index
-rw-r--r-- | src/jv.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -658,12 +658,12 @@ 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)); - p += idxlen; + if (idxlen != 0) { + p = jstr; + while ((p = _jq_memmem(p, (jstr + jlen) - p, idxstr, idxlen)) != NULL) { + a = jv_array_append(a, jv_number(p - jstr)); + p += idxlen; + } } jv_free(j); jv_free(k); |