From a7aa51d8d57a698a5780556e054b2374c48ed5cf Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Sun, 20 Feb 2022 21:25:18 +0100 Subject: [PATCH] Fix unhappy path cleanup. The whole while (cnt-- >= 0) idiom is busted since cnt started at 0 and if the first call to PyUnicode_FromStringAndSize() fails then we're attempting to access -1. --- src/python.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python.c b/src/python.c index cec6a83..8038625 100644 --- a/src/python.c +++ b/src/python.c @@ -1274,8 +1274,8 @@ python_runtime_http_request(void *addr, struct http_request *req) req->cgroups[idx].rm_eo - req->cgroups[idx].rm_so); if (cargs[cnt] == NULL) { - while (cnt-- >= 0) - Py_XDECREF(cargs[cnt]); + while (cnt >= 0) + Py_XDECREF(cargs[cnt--]); kore_python_log_error("http request"); http_response(req, HTTP_STATUS_INTERNAL_ERROR, NULL, 0);