]> granicus.if.org Git - php/commitdiff
Fix for #8539
authorJames Moore <jmoore@php.net>
Mon, 21 May 2001 21:06:08 +0000 (21:06 +0000)
committerJames Moore <jmoore@php.net>
Mon, 21 May 2001 21:06:08 +0000 (21:06 +0000)
ext/cpdf/cpdf.c
ext/pdf/pdf.c

index 628e18effd895c1ad2cd55678d441948f4982bad..67f7d307d8bdddbd973c3a3e70ca62df5a45c6a7 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "php.h"
 #include "php_globals.h"
+#include "zend/zend_list.h"
 #include "ext/standard/php_standard.h"
 #include "ext/standard/head.h"
 #include <math.h>
@@ -66,6 +67,9 @@ static int numthreads=0;
 typedef struct cpdflib_global_struct{
        int le_cpdf;
        int le_outline;
+#if HAVE_LIBGD13
+    int le_gd;
+#endif
 } cpdflib_global_struct;
 
 # define CPDF_GLOBAL(a) cpdflib_globals->a
@@ -76,6 +80,9 @@ typedef struct cpdflib_global_struct{
 #  define CPDF_TLS_VARS
 static int le_cpdf;
 static int le_outline;
+#if HAVE_LIBGD13
+static int le_gd;
+#endif
 #endif
 
 function_entry cpdf_functions[] = {
@@ -2480,7 +2487,14 @@ PHP_FUNCTION(cpdf_place_inline_image) {
 
        gid=argv[1]->value.lval;
        im = zend_list_find(gid, &type);
-       if (!im || type != phpi_get_le_gd()) {
+       
+       ZEND_GET_RESOURCE_TYPE_ID(CPDF_GLOBAL(le_gd),"gd");
+       if(!CPDF_GLOBAL(le_gd))
+       {
+               php_error(E_ERROR, "Unable to find handle for GD image stream. Please check the GD extension is loaded.");
+       }
+
+       if (!im || type != CPDF_GLOBAL(le_gd)) {
                php_error(E_WARNING, "cpdf: Unable to find image pointer");
                RETURN_FALSE;
        }
index d908dadac6f8c45a57d3147aa867b4f5677e6143..f33ce051724ab3eb7c1869bb7d4320b5f821edd8 100644 (file)
@@ -27,6 +27,7 @@
 #include "php.h"
 #include "php_ini.h"
 #include "php_globals.h"
+#include "zend/zend_list.h"
 #include "ext/standard/head.h"
 #include "ext/standard/info.h"
 #include "ext/standard/file.h"
@@ -34,6 +35,7 @@
 #if HAVE_LIBGD13
 #include "ext/gd/php_gd.h"
 #include "gd.h"
+static int le_gd;
 #endif
 
 #ifdef HAVE_UNISTD_H
@@ -1897,7 +1899,12 @@ PHP_FUNCTION(pdf_open_memory_image)
        }
        
        ZEND_FETCH_RESOURCE(pdf, PDF *, arg1, -1, "pdf object", le_pdf);
-       ZEND_FETCH_RESOURCE(im, gdImagePtr, arg2, -1, "Image", phpi_get_le_gd());
+       ZEND_GET_RESOURCE_TYPE_ID(le_gd,"gd");
+       if(!le_gd)
+       {
+               php_error(E_ERROR, "Unable to find handle for GD image stream. Please check the GD extension is loaded.");
+       }
+       ZEND_FETCH_RESOURCE(im, gdImagePtr, arg2, -1, "Image", le_gd);
 
        count = 3 * im->sx * im->sy;
        if(NULL == (buffer = (unsigned char *) emalloc(count))) {