Demo entry 6626919

code2

   

Submitted by anonymous on Jun 27, 2017 at 10:31
Language: C. Code size: 422 Bytes.

/* Dereference null pointers*/
#include <string.h>
#include <stdlib.h>
void f(const char *input_str) {
  size_t size = strlen(input_str) + 1; 
/*If input_str is a null pointer, the call to strlen() dereferences a null pointer*/
  char *c_str = (char *)malloc(size);
 /*If malloc() fails, it returns a null pointer*/
  memcpy(c_str, input_str, size); 
  /* ... */
  free(c_str);
  c_str = NULL;
  /* ... */
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).