summaryrefslogtreecommitdiff
path: root/c/_cffi_backend.c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2018-08-01 22:09:29 +0200
committerArmin Rigo <arigo@tunes.org>2018-08-01 22:09:29 +0200
commit409f7dc9ace9a4493e36b7a7c012adb0a9c5887d (patch)
tree62247ce15d9c8b575604742799eda7bc2b833e30 /c/_cffi_backend.c
parent7b1cdadbeaf47a80d02b0449b858a7b462094566 (diff)
downloadcffi-409f7dc9ace9a4493e36b7a7c012adb0a9c5887d.tar.gz
Issue #372
Fix for architectures where pointers are smaller than sizeof(ffi_arg)
Diffstat (limited to 'c/_cffi_backend.c')
-rw-r--r--c/_cffi_backend.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 998c2ad..5407b7c 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5657,9 +5657,14 @@ static int convert_from_object_fficallback(char *result,
return 0;
}
else if (ctype->ct_flags & (CT_PRIMITIVE_CHAR | CT_PRIMITIVE_SIGNED |
- CT_PRIMITIVE_UNSIGNED)) {
+ CT_PRIMITIVE_UNSIGNED |
+ CT_POINTER | CT_FUNCTIONPTR)) {
/* zero extension: fill the '*result' with zeros, and (on big-
- endian machines) correct the 'result' pointer to write to */
+ endian machines) correct the 'result' pointer to write to.
+ We also do that for pointers, even though we're normally not
+ in this branch because ctype->ct_size == sizeof(ffi_arg) for
+ pointers---except on some architectures like x32 (issue #372).
+ */
memset(result, 0, sizeof(ffi_arg));
#ifdef WORDS_BIGENDIAN
result += (sizeof(ffi_arg) - ctype->ct_size);