From 36d5465d818e0f7a0e83c2a192c2dc5e5bd18468 Mon Sep 17 00:00:00 2001 From: Vincent Castellano Date: Mon, 18 May 2015 13:32:58 -0700 Subject: [PATCH] Fixed string mangling from dirname --- python-tg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python-tg.c b/python-tg.c index f8d0588..a0891f6 100644 --- a/python-tg.c +++ b/python-tg.c @@ -1320,6 +1320,9 @@ void py_init (const char *file) { PyObject* sysPath = PySys_GetObject((char*)"path"); PyList_Append(sysPath, PyUnicode_FromString(dirname(filename))); + // Recopy the string in, since dirname modified it. + strncpy(filename, file, 1024); + // remove .py extension from file, if any char* dot = strrchr(filename, '.'); if (dot && strcmp(dot, ".py") == 0)