diff options
Diffstat (limited to 'python/generator.cpp')
| -rw-r--r-- | python/generator.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/python/generator.cpp b/python/generator.cpp index 3fdf1fc1..c40d8d08 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -567,7 +567,10 @@ int main(int argc, char* argv[]) // Emit wrapper to get Python string and free native memory fprintf(out, "\tresult = "); fprintf(out, "%s\n", stringArgFuncCall.c_str()); - fprintf(out, "\tstring = str(pyNativeStr(ctypes.cast(result, ctypes.c_char_p).value))\n"); + fprintf(out, "\tcasted = ctypes.cast(result, ctypes.c_char_p).value\n"); + fprintf(out, "\tif casted is None:\n"); + fprintf(out, "\t\treturn None\n"); + fprintf(out, "\tstring = str(pyNativeStr(casted))\n"); fprintf(out, "\tBNFreeString(result)\n"); fprintf(out, "\treturn string\n"); } |
