projects
/
jansson.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c21ade4
)
array: Fix a few checks and a leak
author
Petri Lehtinen
<petri@digip.org>
Sun, 23 Aug 2009 10:32:10 +0000
(13:32 +0300)
committer
Petri Lehtinen
<petri@digip.org>
Sun, 23 Aug 2009 10:34:12 +0000
(13:34 +0300)
src/value.c
patch
|
blob
|
history
diff --git
a/src/value.c
b/src/value.c
index
1aaec90
..
fda0b03
100644
(file)
--- 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;
}