summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2015-07-04 22:39:23 +0000
committerchristos <christos@NetBSD.org>2015-07-04 22:39:23 +0000
commit8c2016f73f0219bca8bc5cd4c5805b5e3dcab3fb (patch)
tree75806eeb46451540b6ffdd0196d000023b94d984 /libexec
parentcc08675f5d9170965a6f71bc7f6f00a058f748a2 (diff)
fix memory leaks on error; found by brainy.
Diffstat (limited to 'libexec')
-rw-r--r--libexec/httpd/lua-bozo.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/libexec/httpd/lua-bozo.c b/libexec/httpd/lua-bozo.c
index 48ae58a04ce..972c130bce7 100644
--- a/libexec/httpd/lua-bozo.c
+++ b/libexec/httpd/lua-bozo.c
@@ -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 <marc@msys.ch>
@@ -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);