sqc 0.4.13

Software Code Quality - CERT C compliance checker
/*
 * Rule: MEM35-C
 * Source: wiki
 * Status: FAIL - Should trigger MEM35-C violation
 */

#include <stdint.h>
#include <stdlib.h>
 
void function(size_t len) {
  long *p;
  if (len == 0 || len > SIZE_MAX / sizeof(long)) {
    /* Handle overflow */
  }
  p = (long *)malloc(len * sizeof(int));
  if (p == NULL) {
    /* Handle error */
  }
  free(p);
}