Module Name: src
Committed By: christos
Date: Sat Jul 4 22:39:23 UTC 2015
Modified Files:
src/libexec/httpd: lua-bozo.c
Log Message:
fix memory leaks on error; found by brainy.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/libexec/httpd/lua-bozo.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/libexec/httpd/lua-bozo.c
diff -u src/libexec/httpd/lua-bozo.c:1.11 src/libexec/httpd/lua-bozo.c:1.12
--- src/libexec/httpd/lua-bozo.c:1.11 Fri Aug 15 15:35:28 2014
+++ src/libexec/httpd/lua-bozo.c Sat Jul 4 18:39:23 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: lua-bozo.c,v 1.11 2014/08/15 19:35:28 mbalmer Exp $ */
+/* $NetBSD: lua-bozo.c,v 1.12 2015/07/04 22:39:23 christos Exp $ */
/*
* Copyright (c) 2013 Marc Balmer <[email protected]>
@@ -311,41 +311,38 @@ bozo_process_lua(bozo_httpreq_t *request
if (!httpd->process_lua)
return 0;
+ info = NULL;
+ query = NULL;
+ prefix = NULL;
uri = request->hr_oldfile ? request->hr_oldfile : request->hr_file;
if (*uri == '/') {
file = bozostrdup(httpd, uri);
+ if (file == NULL)
+ goto out;
prefix = bozostrdup(httpd, &uri[1]);
} else {
+ if (asprintf(&file, "/%s", uri) < 0)
+ goto out;
prefix = bozostrdup(httpd, uri);
- asprintf(&file, "/%s", uri);
- }
- if (file == NULL) {
- free(prefix);
- return 0;
}
+ if (prefix == NULL)
+ goto out;
- if (request->hr_query && strlen(request->hr_query))
+ if (request->hr_query && request->hr_query[0])
query = bozostrdup(httpd, request->hr_query);
- else
- query = NULL;
p = strchr(prefix, '/');
- if (p == NULL){
- free(prefix);
- return 0;
- }
+ if (p == NULL)
+ goto out;
*p++ = '\0';
handler = p;
- if (!*handler) {
- free(prefix);
- return 0;
- }
+ if (!*handler)
+ goto out;
p = strchr(handler, '/');
if (p != NULL)
*p++ = '\0';
- info = NULL;
command = file + 1;
if ((s = strchr(command, '/')) != NULL) {
info = bozostrdup(httpd, s);