We now conform to iso-c99
authorTill Riedel <till@ipd.info.uni-karlsruhe.de>
Thu, 26 Jun 2003 11:23:45 +0000 (11:23 +0000)
committerTill Riedel <till@ipd.info.uni-karlsruhe.de>
Thu, 26 Jun 2003 11:23:45 +0000 (11:23 +0000)
fixed array access out of bounds

[r1406]

ir/tv/strcalc.c
ir/tv/tv.c

index b016fb3..20d0cbd 100644 (file)
@@ -1304,7 +1304,7 @@ const char *sc_print(const void *value, unsigned bits, enum base_t base)
   char *pos;
   const char *digits = small_digits;
 
-  pos = output_buffer + BIT_PATTERN_SIZE;
+  pos = output_buffer + BIT_PATTERN_SIZE ;
   *pos = '\0';
 
   /* special case */
@@ -1436,8 +1436,8 @@ void init_strcalc(int precision_in_bytes)
     CALC_BUFFER_SIZE = (4 * precision_in_bytes);
     MAX_VALUE_SIZE   = (2 * precision_in_bytes);
 
-    calc_buffer = malloc(CALC_BUFFER_SIZE * sizeof(char));
-    output_buffer = malloc(BIT_PATTERN_SIZE * sizeof(char));
+    calc_buffer = malloc(CALC_BUFFER_SIZE+1 * sizeof(char));
+    output_buffer = malloc(BIT_PATTERN_SIZE+1 * sizeof(char));
 
     if (calc_buffer == NULL || output_buffer == NULL)
     {
index 3223de8..748f2f8 100644 (file)
@@ -41,6 +41,7 @@
 #include <assert.h>         /* assertions */
 #include <stdlib.h>         /* atoi() */
 #include <string.h>         /* nice things for strings */
+#include <strings.h>         /* nice things for strings */
 
 #include <stdlib.h>
 #include "tv_t.h"