[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#966194: Wrong code in the report



Correct code that created the error message in valgrind:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DIM 32

int main(void)
{
   char *p = NULL;

   p = malloc(DIM);

   if(p == NULL)
   {
      printf("Allocation error.\n");
      exit(1);
   }

   strcpy(p, "This is a test.");

   for(int x = 0 ; x < DIM; ++x)
   {
      printf("%02x ",  p[x]);
   }
   putchar('\n');

   free(p);

   return 0;
}


Reply to: