This is the mail archive of the 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 initilization problem in open_memstream

Hi list,

I just applied the below patch.  I was testing an application which
neglected to print a string which had been created via open_memstream
functionality.  When debugging I found that the buffer was never flushed
in _sflush_r, because a member of the internal memstream structure
hadn't been initialized in internal_open_memstream_r.  The below
patch fixes the problem.


	* libc/stdio/open_memstream.c (internal_open_memstream_r): Initialize
	c->pos to 0.

Index: libc/stdio/open_memstream.c
RCS file: /cvs/src/src/newlib/libc/stdio/open_memstream.c,v
retrieving revision 1.8
diff -u -p -r1.8 open_memstream.c
--- libc/stdio/open_memstream.c	23 Oct 2013 10:04:43 -0000	1.8
+++ libc/stdio/open_memstream.c	20 Feb 2014 13:25:25 -0000
@@ -355,6 +355,7 @@ _DEFUN(internal_open_memstream_r, (ptr, 
   c->storage = c;
   c->pbuf = buf;
   c->psize = size;
+  c->pos = 0;
   c->eof = 0;
   c->saved.w = L'\0';
   c->wide = (int8_t) wide;

Corinna Vinschen
Cygwin Maintainer
Red Hat

Attachment: pgp0I51PRNk9m.pgp
Description: PGP signature

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