aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-07-19 15:00:14 +0000
committerMatt Kraai <kraai@debian.org>2001-07-19 15:00:14 +0000
commitc1cda4a6091902bdb81cb8938838f4b26ddc52cf (patch)
treed372e32f465bdddb1a900a13303ed9ead4d0320f
parent81108e7653583508bfc541748845183c56e0e378 (diff)
downloadbusybox-c1cda4a6091902bdb81cb8938838f4b26ddc52cf.tar.gz
Add a RELEASE_BB_BUFFER macro and use it to fix a memory leak in syslogd.c
(noted by Adam Slattery).
-rw-r--r--busybox.h3
-rw-r--r--include/busybox.h3
-rw-r--r--sysklogd/syslogd.c1
-rw-r--r--syslogd.c1
4 files changed, 8 insertions, 0 deletions
diff --git a/busybox.h b/busybox.h
index e8055b06c..f79dac8c8 100644
--- a/busybox.h
+++ b/busybox.h
@@ -69,13 +69,16 @@ extern const struct BB_applet applets[];
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
+#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
+#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
+#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
#endif
diff --git a/include/busybox.h b/include/busybox.h
index e8055b06c..f79dac8c8 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -69,13 +69,16 @@ extern const struct BB_applet applets[];
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
+#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
+#define RELEASE_BB_BUFFER(buffer) ((void)0)
#else
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
+#define RELEASE_BB_BUFFER(buffer) free (buffer)
#endif
#endif
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 8ae70a1ed..14219eb54 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -431,6 +431,7 @@ static int serveConnection (int conn)
/* Now log it */
logMessage (pri, line);
}
+ RELEASE_BB_BUFFER (tmpbuf);
return n_read;
}
diff --git a/syslogd.c b/syslogd.c
index 8ae70a1ed..14219eb54 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -431,6 +431,7 @@ static int serveConnection (int conn)
/* Now log it */
logMessage (pri, line);
}
+ RELEASE_BB_BUFFER (tmpbuf);
return n_read;
}