aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2009-08-23 13:32:10 +0300
committerPetri Lehtinen <petri@digip.org>2009-08-23 13:34:12 +0300
commit114fc96f761358a0e0c0746674345a537576e2f0 (patch)
tree75c61a0b2aba6084be741743a3df498e2fcc4f4b /src
parentc21ade41e07be9ccf43f5bd8acec87652418a744 (diff)
downloadjansson-114fc96f761358a0e0c0746674345a537576e2f0.zip
jansson-114fc96f761358a0e0c0746674345a537576e2f0.tar.gz
jansson-114fc96f761358a0e0c0746674345a537576e2f0.tar.bz2
array: Fix a few checks and a leak
Diffstat (limited to 'src')
-rw-r--r--src/value.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/value.c b/src/value.c
index 1aaec90..fda0b03 100644
--- a/src/value.c
+++ b/src/value.c
@@ -229,7 +229,7 @@ json_t *json_array_get(const json_t *json, unsigned int index)
return NULL;
array = json_to_array(json);
- if(index >= array->size)
+ if(index >= array->entries)
return NULL;
return array->table[index];
@@ -242,10 +242,12 @@ int json_array_set(json_t *json, unsigned int index, json_t *value)
return -1;
array = json_to_array(json);
- if(index >= array->size)
+ if(index >= array->entries)
return -1;
+ json_decref(array->table[index]);
array->table[index] = json_incref(value);
+
return 0;
}