Skip to content
Browse files

JSStringGetUTF8CString() returns nul-included size

  • Loading branch information...
1 parent d2a79b4 commit ec84ca73ef7cab0eb4b870e11f65801da5382ad5 @gfx committed Jul 16, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 main.c
View
2 main.c
@@ -20,7 +20,7 @@ printJSValueRef(JSContextRef ctx, JSValueRef arg, FILE* fp, JSValueRef* exceptio
size_t const maxSize = JSStringGetMaximumUTF8CStringSize(jstr);
char* const buffer = (char*)malloc(maxSize);
size_t const size = JSStringGetUTF8CString(jstr, buffer, maxSize);
- fwrite(buffer, size, 1, fp);
+ fwrite(buffer, size - 1 /* because nul included */, 1, fp);
free(buffer);
JSStringRelease(jstr);
}

0 comments on commit ec84ca7

Please sign in to comment.
Something went wrong with that request. Please try again.