From: Stefano Rivera <stefanor@debian.org>
Date: Sun, 26 Aug 2018 20:52:13 +0100
Subject: Handle pointers on ILP32 ABIs correctly

Author: Armin Rigo <arigo@tunes.org>
Origin: upstream, https://bitbucket.org/cffi/cffi/commits/f8a530d63fa3680c7bad3d500f36e6b7ba2c8ed2
---
 c/_cffi_backend.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 7106c65..6ac9c50 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5636,9 +5636,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);
