diff --git a/src/stringie.c b/src/stringie.c index 301f25a..ebf547b 100644 --- a/src/stringie.c +++ b/src/stringie.c @@ -16,6 +16,13 @@ } *root; void run(char *); + +char *strdupe(const char *s) +{ + char *t = malloc(strlen(s) + 1); + strcpy(t, s); + return t; +} char *pop(void) { @@ -41,7 +48,7 @@ { char *e, *f; e = pop(); - f = strdup(e); + f = strdupe(e); push(e); push(f); } @@ -167,7 +174,7 @@ int main(int argc, char **argv) { - char *program = strdup(argv[1]); + char *program = strdupe(argv[1]); root = NULL; run(program); exit(0);