From: root <root@yarc.(none)>

This fixes a potential memory leak in case of "m" modifier set
and (sc.width > 0).

Signed-off-by: Pirmin Walthert <in...@nappsoft.com>
---
 libc/stdio/_scanf.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index fe33386..a7592b6 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -1383,11 +1383,11 @@ int VFSCANF (FILE *__restrict fp, const Wchar 
*__restrict format, va_list arg)
                                                i += psfs.store;
                                        }
                                        __scan_ungetc(&sc);
+                                       if (psfs.flags & FLAG_MALLOC)
+                                               *ptr = b;
                                        if (sc.width > 0) {     /* Failed to 
read all required. */
                                                goto DONE;
                                        }
-                                       if (psfs.flags & FLAG_MALLOC)
-                                               *ptr = b;
                                        psfs.cnt += psfs.store;
                                        goto NEXT_FMT;
                                }
-- 
1.7.10.4

_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to