Skip to content

Commit 31c1f13

Browse files
committed
modffi: 's' (string) return type: handle NULL properly (return None).
1 parent 32444b7 commit 31c1f13

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

unix/modffi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
140140
switch (type) {
141141
case 's': {
142142
const char *s = (const char *)val;
143+
if (!s) {
144+
return mp_const_none;
145+
}
143146
return mp_obj_new_str(s, strlen(s), false);
144147
}
145148
case 'v':

0 commit comments

Comments
 (0)