sqc 0.4.13

Software Code Quality - CERT C compliance checker
/*
 * Rule: MEM04-C
 * Source: wiki
 * Status: PASS - Should NOT trigger MEM04-C violation
 */

size_t nsize;
/* Initialize nsize */
char *p2;
char *p = (char *)malloc(100);
if (p == NULL) {
  /* Handle error */
}

/* ... */

p2 = NULL;
if (nsize != 0) {
  p2 = (char *)realloc(p, nsize);
}
if (p2 == NULL) {
  free(p);
  p = NULL;
  return NULL;
}
p = p2;