From c2679eff9a842faef8e99244f2f917d4f4a04d2c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 30 Jun 2018 18:15:08 +0530 Subject: [PATCH] Fix compiler warning The compiler warning is harmless, since we exec immediately after using the const char* but since I have a no warning policy... --- kitty/child.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kitty/child.c b/kitty/child.c index a95d25a41..d5c6876fb 100644 --- a/kitty/child.c +++ b/kitty/child.c @@ -17,7 +17,13 @@ serialize_string_tuple(PyObject *src) { Py_ssize_t sz = PyTuple_GET_SIZE(src); char **ans = calloc(sz + 1, sizeof(char*)); if (!ans) fatal("Out of memory"); - for (Py_ssize_t i = 0; i < sz; i++) ans[i] = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i)); + for (Py_ssize_t i = 0; i < sz; i++) { + const char *pysrc = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i)); + size_t len = strlen(pysrc); + ans[i] = calloc(len + 1, sizeof(char)); + if (ans[i] == NULL) fatal("Out of memory"); + memcpy(ans[i], pysrc, len); + } return ans; }