diff options
-rw-r--r-- | parsing.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -56,6 +56,8 @@ char *substr(const char *head, const char *tail) | |||
56 | { | 56 | { |
57 | char *buf; | 57 | char *buf; |
58 | 58 | ||
59 | if (tail < head) | ||
60 | return xstrdup(""); | ||
59 | buf = xmalloc(tail - head + 1); | 61 | buf = xmalloc(tail - head + 1); |
60 | strncpy(buf, head, tail - head); | 62 | strncpy(buf, head, tail - head); |
61 | buf[tail - head] = '\0'; | 63 | buf[tail - head] = '\0'; |