From 64fbacabbee4c8cb575d288367e2c95f2c7cbc8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Thu, 5 Jun 2025 07:14:21 +0200 Subject: [PATCH] python: reset pointer after asprintf failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Erik Sjölund --- python/crun_python.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/crun_python.c b/python/crun_python.c index 1ffc3fff..417dd4fb 100644 --- a/python/crun_python.c +++ b/python/crun_python.c @@ -55,6 +55,8 @@ set_error (libcrun_error_t *err) ret = asprintf (&msg, "%s: %s", (*err)->msg, strerror ((*err)->status)); if (LIKELY (ret >= 0)) PyErr_SetString (PyExc_RuntimeError, msg); + else + msg = NULL; } libcrun_error_release (err); @@ -405,6 +407,8 @@ container_update (PyObject *self arg_unused, PyObject *args) ret = asprintf (&msg, "cannot parse process: %s", parser_err); if (LIKELY (ret >= 0)) PyErr_SetString (PyExc_RuntimeError, msg); + else + msg = NULL; free (parser_err); return NULL; }