home · contact · privacy
Test return values of _all_ *printf() calls.
[plomrogue] / src / client / io.c
index 31387f26d8466aeade7e293d2be5d06b0937aad2..c047f6985d3f9526cc45eb4fa845be77ad9677e2 100644 (file)
@@ -106,7 +106,8 @@ static void read_inventory(char * read_buf, uint32_t linemax, FILE * file)
         int new_size = strlen(read_buf);
         char * new_inventory = try_malloc(old_size + new_size + 1, f_name);
         memcpy(new_inventory, world.player_inventory, old_size);
-        sprintf(new_inventory + old_size, "%s", read_buf);
+        int test = sprintf(new_inventory + old_size, "%s", read_buf);
+        exit_trouble(test < 0, f_name, "sprintf()");
         free(world.player_inventory);
         world.player_inventory = new_inventory;
     }
@@ -150,7 +151,8 @@ static void read_log(char * read_buf, uint32_t linemax, FILE * file)
         int new_size = strlen(read_buf);
         char * new_log = try_malloc(old_size + new_size + 1, f_name);
         memcpy(new_log, world.log, old_size);
-        sprintf(new_log + old_size, "%s", read_buf);
+        int test = sprintf(new_log + old_size, "%s", read_buf);
+        exit_trouble(test < 0, f_name, "sprintf()");
         free(world.log);
         world.log = new_log;
     }