Skip to content

Instantly share code, notes, and snippets.

@mopp
Created November 7, 2014 16:06
Show Gist options
  • Save mopp/43091cd7d4a1213310b8 to your computer and use it in GitHub Desktop.
Save mopp/43091cd7d4a1213310b8 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char* global_strs = NULL;
void do_free(void) {
if (global_strs != NULL) {
free(global_strs);
puts("freed.");
} else {
puts("global_strs is already freed.");
}
}
int main(int argc, char const* argv[]) {
global_strs = malloc(1000 * sizeof(char));
memset(global_strs, 0x1b, 1000 * sizeof(char));
puts("malloced");
do_free();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment