Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added includes

...

Code Block
bgColor#FFCCCC
langc
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
 
errno_t f(void) { 
  png_charp chunkdata;
  chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
  /* ... */
  return 0;
}

...

Code Block
bgColor#ccccff
langc
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
 
errno_t f(void) { 
  png_charp chunkdata;
  chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
  if (NULL == chunkdata) {
    return ENOMEM;  /* Indicate failure */
  }
  /* ... */
  return 0;
}

...

Code Block
bgColor#FFCCCC
langc
#include <string.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
 
errno_t f(void) {
  size_t size = strlen(input_str)+1;
  str = (char *)malloc(size);
  memcpy(str, input_str, size);
  /* ... */
  free(str);
  str = NULL;

  return 0;
}

...

Code Block
bgColor#ccccff
langc
#include <string.h>
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
 
errno_t f(void) {
  size_t size = strlen(input_str)+1;
  str = (char *)malloc(size);
  if (NULL == str) {
    return ENOMEM; /* Indicate allocation failure */
  }
  memcpy(str, input_str, size);
  /* ... */
  free(str);
  str = NULL;

  /* ... */
  return 0;
}

...