Browse Source

Fix NULL pointer dereference in open_memstream()

--000000000000cb1b1305827e5ae0
Content-Type: text/plain; charset="UTF-8"

Hi,

Current version of uClibc-ng has issue in open_memstream() function.
If the cookie variable is NULL (due malloc() fail) then null pointer is
dereferenced after if block.

The attached patch fixes this issue.
--
Best regards,
Eugene

<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>Current version of uClibc-ng has issue in open_memstream() function.</div><div>If the cookie variable is NULL (due malloc() fail) then null pointer is dereferenced after if block.</div><div><br></div><div>The attached patch fixes this issue.<br clear="all"><div>-- <br></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div><span><div>Best regards,<br></div>Eugene</span></div></div></div></div></div></div></div></div></div>
Eugene Yudin 5 years ago
parent
commit
5efc10d24e
1 changed files with 2 additions and 1 deletions
  1. 2 1
      libc/stdio/open_memstream.c

+ 2 - 1
libc/stdio/open_memstream.c

@@ -156,9 +156,10 @@ FILE *open_memstream(char **bufloc, size_t *sizeloc)
 			__STDIO_STREAM_VALIDATE(fp);
 			return fp;
 		}
+
+		free(cookie->buf);
 	}
 
-	free(cookie->buf);
  EXIT_cookie:
 	free(cookie);