This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[ob/patch] libc/stdio/vfprintf.c: Using wrong pointer in `ls' string handling


Hi,

I applied the below patch as obvious.  The preceding code takes care to
use either an allocated buffer, or the existing `buf' buffer as target
buffer, depending of the size of the target string.  cp is set
accordingly.  Unfortunately cp isn't used in the call to _wcsrtombs_r,
but malloc_buf, which can be NULL here.


Corinna


	* libc/stdio/vfprintf.c (_VFPRINTF_R): Use correct pointer in call to
	_wcsrtombs_r.


Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.67
diff -u -p -r1.67 vfprintf.c
--- libc/stdio/vfprintf.c       13 Oct 2007 15:26:20 -0000      1.67
+++ libc/stdio/vfprintf.c       19 Dec 2007 16:58:53 -0000
@@ -1095,8 +1095,8 @@ reswitch: switch (ch) {
 
                                /* Convert widechar string to multibyte string. */
                                memset ((_PTR)&ps, '\0', sizeof (mbstate_t));
-                               if (_wcsrtombs_r (data, malloc_buf,
-                                                &wcp, size, &ps) != size) {
+                               if (_wcsrtombs_r (data, cp, &wcp, size, &ps)
+                                   != size) {
                                        fp->_flags |= __SERR;
                                        goto error;
                                }


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]