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]

[patch] fix printf("%p") (lesstif / XPDF crash)


Currently sprintf("%p") does not work because the path taken for
handling %p shares most of the code with %x but fails to populate the
char ox[2] used to emit the prefix, resulting in two uninitialized
characters being written instead of 'Ox'.

This is what was causing the Xpdf segfault under Cygwin, which happened
deep in the guts of lesstif due to:

	    /* This pixmap has never been seen before.  Generate
	     * a unique name and add it to the cache.  The cache
	     * mechanism will obtain the depth.  Then we can try
	     * again.
	     */
	    char newname[64] ;
	    sprintf(newname, "--anon pixmap %p-%x",
	      (void *)XtScreen(w),
	      (unsigned)mypm) ;

Fix attached.

Brian
2007-05-27  Brian Dessent  <brian@dessent.net>

	* libc/stdio/vfprintf.c (_VFPRINTF_R): Populate 'ox' when handling %p.


Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
retrieving revision 1.61
diff -u -p -r1.61 vfprintf.c
--- libc/stdio/vfprintf.c	23 May 2007 20:36:28 -0000	1.61
+++ libc/stdio/vfprintf.c	27 May 2007 12:46:54 -0000
@@ -1022,6 +1022,8 @@ reswitch:	switch (ch) {
 			xdigs = "0123456789abcdef";
 			flags |= HEXPREFIX;
 			ch = 'x';
+			ox[0] = '0';
+			ox[1] = ch;
 			goto nosign;
 		case 's':
 #ifdef _WANT_IO_C99_FORMATS

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