summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-06-13 18:08:48 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-06-13 18:08:48 -0700
commit023c7e53fa672c105d99612fab54c0aa4b381eac (patch)
treef9c19d56a5f428e6bb17371fd397a14b4d45b5b6
parent0ce67c1545e6e2d75200d6876b425c00e4c39541 (diff)
downloadffi-yajl-023c7e53fa672c105d99612fab54c0aa4b381eac.tar.gz
fix very long nums/strings/keys
-rw-r--r--ext/ffi_yajl/ext/parser/parser.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/ffi_yajl/ext/parser/parser.c b/ext/ffi_yajl/ext/parser/parser.c
index 837093a..1f88442 100644
--- a/ext/ffi_yajl/ext/parser/parser.c
+++ b/ext/ffi_yajl/ext/parser/parser.c
@@ -74,7 +74,7 @@ int double_callback(void *ctx, double doubleVal) {
}
int number_callback(void *ctx, const char *numberVal, size_t numberLen) {
- char buf[numberLen+1];
+ char *buf = (char *)malloc(numberLen+1);
buf[numberLen] = 0;
memcpy(buf, numberVal, numberLen);
if (memchr(buf, '.', numberLen) ||
@@ -84,11 +84,12 @@ int number_callback(void *ctx, const char *numberVal, size_t numberLen) {
} else {
set_value(ctx, rb_cstr2inum(buf, 10));
}
+ free(buf);
return 1;
}
int string_callback(void *ctx, const unsigned char *stringVal, size_t stringLen) {
- char buf[stringLen+1];
+ char *buf = (char *)malloc(stringLen+1);
VALUE str;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding *default_internal_enc;
@@ -105,6 +106,7 @@ int string_callback(void *ctx, const unsigned char *stringVal, size_t stringLen)
}
#endif
set_value(ctx,str);
+ free(buf);
return 1;
}
@@ -114,7 +116,7 @@ int start_map_callback(void *ctx) {
}
int map_key_callback(void *ctx, const unsigned char *stringVal, size_t stringLen) {
- char buf[stringLen+1];
+ char *buf = (char *)malloc(stringLen+1);
VALUE str;
#ifdef HAVE_RUBY_ENCODING_H
rb_encoding *default_internal_enc;
@@ -131,6 +133,7 @@ int map_key_callback(void *ctx, const unsigned char *stringVal, size_t stringLen
}
#endif
set_key(ctx,str);
+ free(buf);
return 1;
}