lkml.org 
[lkml]   [2014]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/1] Memory leak in scripts/dtc/util.c
Date
From: Heinrich Schuchardt <xypron.glpk@gmx.de>

buf was leaked if out of memory

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
scripts/dtc/util.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/scripts/dtc/util.c b/scripts/dtc/util.c
index 2422c34..a1e2e59 100644
--- a/scripts/dtc/util.c
+++ b/scripts/dtc/util.c
@@ -210,9 +210,11 @@ int utilfdt_read_err(const char *filename, char **buffp)
do {
/* Expand the buffer to hold the next chunk */
if (offset == bufsize) {
+ char *buf_old = buf;
bufsize *= 2;
buf = realloc(buf, bufsize);
if (!buf) {
+ buf = buf_old;
ret = ENOMEM;
break;
}
--
1.7.10.4


\
 
 \ /
  Last update: 2014-02-27 20:01    [W:0.054 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site