Permalink
Browse files

backported NIF fix to R13 version

  • Loading branch information...
1 parent 6fc0799 commit 1b3901f266081fb33361d1fe00637e3a6e05ab16 Richard Carlsson committed Jun 6, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 chapter_12/nifs/json_parser/c_src/jp_nifs_R13.c
@@ -155,7 +155,7 @@ static void add_element(state_t *st, ERL_NIF_TERM t)
{
container_t *c = st->c;
if (c != NULL) {
- if (c->count >= c->arraysz) {
+ if (c->count * sizeof(ERL_NIF_TERM) >= c->arraysz) {
c->arraysz *= 2;
c->array = enif_realloc(st->env, c->array, c->arraysz);
}
@@ -266,6 +266,7 @@ static int handle_end(void *ctx, int array)
c->count));
}
/* decallocate used container struct */
+ enif_free(st->env, c->array);
enif_free(st->env, c);
return 1;
}

0 comments on commit 1b3901f

Please sign in to comment.