summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Williams <nico@cryptonector.com>2019-02-09 16:32:20 -0600
committerGitHub <noreply@github.com>2019-02-09 16:32:20 -0600
commit9fa2e51099c55af56e3e541dc4b399f11de74abe (patch)
tree0fc0322e726f9a6eb8637defbff27b28c316cce0
parent88613f546926a7737af7542bf0a74a22d935cd14 (diff)
parent3f59bee3e080c4b1ee2ae94244ac0263a69999d2 (diff)
Merge pull request #1818 from muhmuhten/free_in_index
-rw-r--r--src/jv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/jv.c b/src/jv.c
index b3fcd5e3..06b4e6a2 100644
--- a/src/jv.c
+++ b/src/jv.c
@@ -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);