Browse Source

Merge pull request #3 from Kira-sempai/addBufLenCheck

Check if we have enough place to add quotes
Sergey Lyubka 11 years ago
parent
commit
c4e4106dbf
1 changed files with 2 additions and 0 deletions
  1. 2 0
      frozen.c

+ 2 - 0
frozen.c

@@ -362,6 +362,8 @@ int json_emit_double(char *buf, int buf_len, double value) {
 int json_emit_quoted_str(char *buf, int buf_len, const char *str) {
   int i = 0, j = 0, ch;
 
+  if (buf_len <= 1) return 0;
+
 #define EMIT(x) do { if (j < buf_len) buf[j++] = x; } while (0)
 
   EMIT('"');