From 31c1f1300e2f166061cb0a491fab30ac37018a94 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 25 Jan 2015 00:42:39 +0200 Subject: [PATCH] modffi: 's' (string) return type: handle NULL properly (return None). --- unix/modffi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/unix/modffi.c b/unix/modffi.c index 7c87e5b01a..6e0f06ec77 100644 --- a/unix/modffi.c +++ b/unix/modffi.c @@ -140,6 +140,9 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type) switch (type) { case 's': { const char *s = (const char *)val; + if (!s) { + return mp_const_none; + } return mp_obj_new_str(s, strlen(s), false); } case 'v':