]> granicus.if.org Git - php/commitdiff
fix #33383 (crash when retrieving empty LOBs)
authorAntony Dovgal <tony2001@php.net>
Mon, 10 Oct 2005 10:41:24 +0000 (10:41 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 10 Oct 2005 10:41:24 +0000 (10:41 +0000)
ext/oci8/oci8.c

index 201ac7874ccdc92b9debe451a855d85a1f31c712..a9245697a0d128c39e94f8d021f9928e659adade 100644 (file)
@@ -1285,7 +1285,12 @@ _oci_make_zval(zval *value,oci_statement *statement,oci_out_column *column, char
                        if (oci_loadlob(statement->conn,descr,&buffer,&loblen)) {
                                ZVAL_FALSE(value);
                        } else {
-                               ZVAL_STRINGL(value,buffer,loblen,0);
+                               if (loblen > 0) {
+                                       ZVAL_STRINGL(value,buffer,loblen,0);
+                               }
+                               else {
+                                       ZVAL_EMPTY_STRING(value);
+                               }
                        } 
                } else { 
                        /* return the locator */
@@ -1912,6 +1917,10 @@ oci_loadlob(oci_connection *connection, oci_descriptor *mydescr, char **buffer,u
                return -1;
        }
 
+       if (readlen == 0) {
+               return 0;
+       }
+       
        buf = emalloc(readlen + 1);
 
        while (readlen > 0) { /* thies loop should not be entered on readlen == 0 */
@@ -2527,7 +2536,7 @@ static oci_server *_oci_open_server(char *dbname,int persistent)
                        /* breakthru to open */
                }
        }
-       
+
        server = calloc(1,sizeof(oci_server));
 
        server->persistent = persistent;
@@ -3286,7 +3295,12 @@ PHP_FUNCTION(ociloadlob)
                }
 
                if (!oci_loadlob(descr->conn,descr,&buffer,&loblen)) {
-                       RETURN_STRINGL(buffer,loblen,0);
+                       if (loblen > 0) {
+                               RETURN_STRINGL(buffer,loblen,0);
+                       }
+                       else {
+                               RETURN_EMPTY_STRING();
+                       }
                }
        }