Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/httpd ...and free() memory malloc()ed by scandir so ...
details: https://anonhg.NetBSD.org/src/rev/5781c53cd622
branches: trunk
changeset: 757155:5781c53cd622
user: dogcow <dogcow%NetBSD.org@localhost>
date: Mon Aug 16 18:32:44 2010 +0000
description:
...and free() memory malloc()ed by scandir so we don't leak.
diffstat:
libexec/httpd/dir-index-bozo.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diffs (48 lines):
diff -r 1f02bd0f766d -r 5781c53cd622 libexec/httpd/dir-index-bozo.c
--- a/libexec/httpd/dir-index-bozo.c Mon Aug 16 17:58:42 2010 +0000
+++ b/libexec/httpd/dir-index-bozo.c Mon Aug 16 18:32:44 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dir-index-bozo.c,v 1.9 2010/08/16 10:00:56 dogcow Exp $ */
+/* $NetBSD: dir-index-bozo.c,v 1.10 2010/08/16 18:32:44 dogcow Exp $ */
/* $eterna: dir-index-bozo.c,v 1.17 2010/05/10 02:51:28 mrg Exp $ */
@@ -61,13 +61,13 @@
{
bozohttpd_t *httpd = request->hr_httpd;
struct stat sb;
- struct dirent **de;
+ struct dirent **de, **deo;
struct tm *tm;
DIR *dp;
char buf[MAXPATHLEN];
char spacebuf[48];
char *file = NULL;
- int l, j, i;
+ int l, k, j, i;
if (!isindex || !httpd->dir_indexing)
return 0;
@@ -123,7 +123,8 @@
directory_hr(httpd);
bozo_printf(httpd, "<pre>");
- for (j = scandir(dirname, &de, NULL, alphasort); j--; de++) {
+ for (j = k = scandir(dirname, &de, NULL, alphasort), deo = de;
+ j--; de++) {
int nostat = 0;
char *name = (*de)->d_name;
@@ -183,9 +184,10 @@
bozo_printf(httpd, "\r\n");
}
- if (de)
- free(de);
closedir(dp);
+ while (k--)
+ free(deo[k]);
+ free(deo);
bozo_printf(httpd, "</pre>");
directory_hr(httpd);
bozo_printf(httpd, "</body></html>\r\n\r\n");
Home |
Main Index |
Thread Index |
Old Index