guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-15-16-g99


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-15-16-g9970cf6
Date: Tue, 08 Feb 2011 23:08:19 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=9970cf67080b48ec35680c70146500428b47bf3e

The branch, master has been updated
       via  9970cf67080b48ec35680c70146500428b47bf3e (commit)
      from  6090483143d53a136e46186887edb3961b825682 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9970cf67080b48ec35680c70146500428b47bf3e
Author: Ludovic Courtès <address@hidden>
Date:   Wed Feb 9 00:08:14 2011 +0100

    Improve type checking when invoking foreign functions.
    
    * libguile/foreign.c (unpack): Make sure X is a pointer before using
      `SCM_POINTER_VALUE'.
    
    * test-suite/tests/foreign.test ("pointer->procedure"): New test prefix.

-----------------------------------------------------------------------

Summary of changes:
 libguile/foreign.c            |    4 ++++
 test-suite/tests/foreign.test |    8 ++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/libguile/foreign.c b/libguile/foreign.c
index 52da23f..c546c79 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -814,6 +814,7 @@ cif_to_procedure (SCM cif, SCM func_ptr)
 /* Set *LOC to the foreign representation of X with TYPE.  */
 static void
 unpack (const ffi_type *type, void *loc, SCM x)
+#define FUNC_NAME "scm_i_foreign_call"
 {
   switch (type->type)
     {
@@ -848,15 +849,18 @@ unpack (const ffi_type *type, void *loc, SCM x)
       *(scm_t_int64 *) loc = scm_to_int64 (x);
       break;
     case FFI_TYPE_STRUCT:
+      SCM_VALIDATE_POINTER (1, x);
       memcpy (loc, SCM_POINTER_VALUE (x), type->size);
       break;
     case FFI_TYPE_POINTER:
+      SCM_VALIDATE_POINTER (1, x);
       *(void **) loc = SCM_POINTER_VALUE (x);
       break;
     default:
       abort ();
     }
 }
+#undef FUNC_NAME
 
 /* Return a Scheme representation of the foreign value at LOC of type TYPE.  */
 static SCM
diff --git a/test-suite/tests/foreign.test b/test-suite/tests/foreign.test
index ba53a0d..3569c8a 100644
--- a/test-suite/tests/foreign.test
+++ b/test-suite/tests/foreign.test
@@ -137,6 +137,14 @@
         (string=? s (pointer->string (string->pointer s)))))))
 
 
+(with-test-prefix "pointer->procedure"
+
+  (pass-if-exception "object instead of pointer"
+    exception:wrong-type-arg
+    (let ((p (pointer->procedure '* %null-pointer '(*))))
+      (p #t))))
+
+
 (with-test-prefix "procedure->pointer"
 
   (define qsort


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]