Skip to content

Commit 0c16490

Browse files
committed
Correct use of CACHE_EXSTRP
1 parent 085cd02 commit 0c16490

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

c/iscpython.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
============================================================================
99
*/
1010

11+
#define USE_CALLIN_CHAR
12+
1113
#define ZF_DLL /* Required only for dynamically linked libraries. */
1214

1315
#include <cdzf.h>
@@ -118,8 +120,15 @@ int SimpleString(CACHE_EXSTRP command, char *resultVar, int serialization, CACHE
118120
Initialize();
119121
}
120122

121-
PyRun_SimpleString((char*)command->str.ch);
123+
// Copy command text to a new pointer and add null at the end
124+
char* commandChar = malloc(1 + sizeof(char)*command->len);
125+
memcpy(commandChar, command->str.ch, command->len);
126+
memcpy(commandChar + command->len, "\0", 1);
127+
128+
PyRun_SimpleString(commandChar);
129+
122130
CACHEEXSTRKILL(command);
131+
free(commandChar);
123132

124133
int exists = PyObject_HasAttrString(mainModule, resultVar);
125134

0 commit comments

Comments
 (0)