Skip to content

Instantly share code, notes, and snippets.

@mzyy94
Last active December 31, 2015 16:59
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 mzyy94/8017103 to your computer and use it in GitHub Desktop.
Save mzyy94/8017103 to your computer and use it in GitHub Desktop.
Segmentation faultとBus errorを再現するためのもの
int main(int argc, char* argv[]) {
unsigned char c[1];
static unsigned char s[1];
char mode = argc == 2 ? argv[1][0] : '\0';
for(int i = 0; ; i++){
switch(mode) {
case '0':
c[0] = s[i];
break;
case '1':
s[i] = '\0';
break;
case '2':
s[0] = c[i];
break;
default:
c[i] = '\0';
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment