changeset 222:723a69185102

Fix th_str{n}dup_trim() functions.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 15 Feb 2016 10:45:05 +0200
parents 81b4688f684b
children d58b92ef5c03
files th_string.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/th_string.c	Mon Feb 15 10:13:08 2016 +0200
+++ b/th_string.c	Mon Feb 15 10:45:05 2016 +0200
@@ -74,7 +74,10 @@
         end = len;
 
     // Allocate memory for result
-    len = end - start + 1;
+    len = end - start;
+    if (len == 0)
+        return NULL;
+
     if ((res = th_malloc(len + 1)) == NULL)
         return NULL;