]> granicus.if.org Git - recode/commitdiff
request.c: zero realloc’d memory
authorReuben Thomas <rrt@sc3d.org>
Sat, 27 Jan 2018 14:14:46 +0000 (14:14 +0000)
committerReuben Thomas <rrt@sc3d.org>
Sun, 28 Jan 2018 22:41:22 +0000 (22:41 +0000)
For some reason this was being found by Valgrind on Travis, but not on my
dev machine.

src/request.c

index 02c34938ecef80d2f3d7937ffe9c63a721e4cad2..fede25a71cb6941af3975bb9f45084330d7542bb 100644 (file)
@@ -218,6 +218,8 @@ add_to_sequence (RECODE_REQUEST request, RECODE_SINGLE single,
 
   if ((unsigned)request->sequence_length == request->sequence_allocated)
     {
+      unsigned old_allocated = request->sequence_allocated;
+
       if (request->sequence_allocated == 0)
        request->sequence_allocated = 16;
       else
@@ -229,6 +231,9 @@ add_to_sequence (RECODE_REQUEST request, RECODE_SINGLE single,
          recode_error (outer, _("Virtual memory exhausted!"));
          return false;
        }
+
+      memset (request->sequence_array + old_allocated, 0,
+              (request->sequence_allocated - old_allocated) * sizeof (struct recode_step));
     }
 
   step = request->sequence_array + request->sequence_length++;