Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
 libc/stdio/getdelim.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c
index 987e32a..c264b32 100644
--- a/libc/stdio/getdelim.c
+++ b/libc/stdio/getdelim.c
@@ -30,7 +30,7 @@ ssize_t getdelim(char **__restrict lineptr, size_t 
*__restrict n,
 {
        register char *buf;
        ssize_t pos = -1;
-       int c;
+       int ch;
        __STDIO_AUTO_THREADLOCK_VAR;
 
        if (!lineptr || !n || !stream) { /* Be compatable with glibc... even */
@@ -49,18 +49,17 @@ ssize_t getdelim(char **__restrict lineptr, size_t 
*__restrict n,
                pos = 1;
 
                do {
-                       if (pos >= *n) {
-                               if (!(buf = realloc(buf, *n + 
GETDELIM_GROWBY))) {
+                       if ((size_t)pos >= *n) {
+                               if (!(buf = realloc(buf, *n += 
GETDELIM_GROWBY))) {
                                        pos = -1;
                                        break;
                                }
-                               *n += GETDELIM_GROWBY;
                                *lineptr = buf;
                        }
 
-                       if ((c = __GETC_UNLOCKED(stream)) != EOF) {
-                               buf[++pos - 2] = c;
-                               if (c != delimiter) {
+                       if ((ch = __GETC_UNLOCKED(stream)) != EOF) {
+                               buf[++pos - 2] = ch;
+                               if (ch != delimiter) {
                                        continue;
                                }
                        }
-- 
1.7.6.3

_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to