[Pkg-libvirt-commits] [SCM] Libguestfs Debian packaging branch, experimental, updated. debian/1%1.21.40-1

Richard W.M. Jones rjones at redhat.com
Sat Jun 1 11:04:48 UTC 2013


The following commit has been merged in the experimental branch:
commit f9eee0ad8de7a50e769d6f3621329e411b546605
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Fri May 17 11:54:07 2013 +0100

    php: Work around buggy PHP returning array as long.
    
    Because OStringList is an optarg, we must specify "a!"  to
    zend_parse_parameters.
    
    However zend_parse_parameters still returns this as a *long* rather
    than a NULL (or empty array) so positively check that it has returned
    an array.

diff --git a/generator/php.ml b/generator/php.ml
index cc131ef..f27c5f4 100644
--- a/generator/php.ml
+++ b/generator/php.ml
@@ -252,7 +252,11 @@ PHP_FUNCTION (guestfs_last_error)
                 | OBool _ -> "b"
                 | OInt _ | OInt64 _ -> "l"
                 | OString _ -> "s"
-                | OStringList _ -> "a"
+                | OStringList _ ->
+                  (* Because this is an optarg, it can be passed as
+                   * NULL, so we must add '!' afterwards.
+                   *)
+                  "a!"
               ) optargs
             )
         else param_string in
@@ -363,7 +367,10 @@ PHP_FUNCTION (guestfs_last_error)
             pr "  }\n"
           | OStringList n ->
             let uc_n = String.uppercase n in
-            pr "  if (optargs_t_%s != NULL && ! ZVAL_IS_NULL (optargs_t_%s)) {\n" n n;
+            pr "  /* We've seen PHP give us a *long* here when we asked for an array, so\n";
+            pr "   * positively check that it gave us an array, otherwise ignore it.\n";
+            pr "   */\n";
+            pr "  if (optargs_t_%s != NULL && Z_TYPE_P (optargs_t_%s) == IS_ARRAY) {\n" n n;
             pr "    char **r;\n";
             pr "    HashTable *a;\n";
             pr "    int n;\n";

-- 
Libguestfs Debian packaging



More information about the Pkg-libvirt-commits mailing list