summaryrefslogtreecommitdiffhomepage
path: root/examples/strsep-invalid-free.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/strsep-invalid-free.c')
-rw-r--r--examples/strsep-invalid-free.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/strsep-invalid-free.c b/examples/strsep-invalid-free.c
new file mode 100644
index 0000000..e01685d
--- /dev/null
+++ b/examples/strsep-invalid-free.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(void)
+{
+ char *str = strdup("Hello World"), *tkn;
+
+ printf("str [%s@%p]\n", str, str);
+ tkn = strsep(&str, " ");
+ printf("tkn [%s] str [%s@%p]\n", tkn, str, str);
+
+ free(str);
+
+ return 0;
+}