fix errors reported by valgrind
authorLaurent Mazet <mazet@softndesign.org>
Wed, 19 Jun 2024 10:17:14 +0000 (12:17 +0200)
committerLaurent Mazet <mazet@softndesign.org>
Wed, 19 Jun 2024 10:17:14 +0000 (12:17 +0200)
function.c

index 692c52fc1910345debdba905d544222bd2d54df9..f217027515ea6373d90039cf6972df57f5fa52fa 100644 (file)
@@ -104,6 +104,7 @@ draw_t *newdraw (int nbtiles)
     CHECKALLOC (draw->tiles);
     memset (draw->tiles, ' ', nbtiles);
     draw->nbtiles = nbtiles;
+    draw->index = -1;
     return draw;
 }
 
@@ -609,7 +610,7 @@ char *loaddata (char *filename)
     if (fd) {
         fseek (fd, 0, SEEK_END);
         int size = ftell (fd);
-        buffer = (char *) calloc (size, 1);
+        buffer = (char *) calloc (size + 1, 1);
         CHECKALLOC (buffer);
 
         fseek (fd, 0, SEEK_SET);