changeset 206:c2193323736d

Fix thfgets().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 12 Feb 2016 00:16:49 +0200
parents c42a9c3f4d55
children 75dbac8f2f59
files th_ioctx.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/th_ioctx.c	Thu Feb 11 23:41:26 2016 +0200
+++ b/th_ioctx.c	Fri Feb 12 00:16:49 2016 +0200
@@ -213,7 +213,8 @@
 
 char *thfgets(char *str, int size, th_ioctx *ctx)
 {
-    char *ptr = str, *end = str + size - 1, c;
+    char *ptr = str, *end = str + size - 1;
+    int c;
 
     if (size <= 0)
         return NULL;
@@ -224,7 +225,7 @@
         if (c == '\n')
             break;
     }
-    *ptr++ = 0;
+    *ptr = 0;
 
     return (ptr > str) ? str : NULL;
 }