Skip to content

Instantly share code, notes, and snippets.

@moyix
Created July 8, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyix/11bc2a9ccf1074aaeb72473644bf7084 to your computer and use it in GitHub Desktop.
Save moyix/11bc2a9ccf1074aaeb72473644bf7084 to your computer and use it in GitHub Desktop.
Example of an invalid mutation
#include <stdio.h>
#include <string.h>
int main(void) {
const char *foo = "this is a test";
char prefix[4] = {};
strncpy(prefix, foo, 4);
// BUGGY: strcpy(prefix, foo);
printf("Prefix: %.4s\n", prefix);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment