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

index 9df7318f46261cc6720a928e43d07209653b678f..361a796cd1e7d4ff669cbe6f8ffeabf7c07094b2 100644 (file)
@@ -1490,7 +1490,12 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode TSR
                                ZVAL_FALSE(value);
                                return 1;
                        } else {
-                               ZVAL_STRINGL(value, lob_buffer, lob_length, 0);
+                               if (lob_length > 0) {
+                                       ZVAL_STRINGL(value, lob_buffer, lob_length, 0);
+                               }
+                               else {
+                                       ZVAL_EMPTY_STRING(value);
+                               }
                                return 0;
                        }
                } else { 
index 7b008e02d944f7d4eb302e7674f11ea55b083ca5..71191c1f1ad028dd52d43ae265dc7fef90765052 100644 (file)
@@ -243,7 +243,12 @@ PHP_FUNCTION(oci_lob_load)
        if (php_oci_lob_read(descriptor, -1, 0, &buffer, &buffer_len TSRMLS_CC)) {
                RETURN_FALSE;
        }
-       RETURN_STRINGL(buffer, buffer_len, 0);
+       if (buffer_len > 0) {
+               RETURN_STRINGL(buffer, buffer_len, 0);
+       }
+       else {
+               RETURN_EMPTY_STRING();
+       }
 }
 /* }}} */
 
@@ -282,8 +287,13 @@ PHP_FUNCTION(oci_lob_read)
        
        if (php_oci_lob_read(descriptor, length, descriptor->lob_current_position, &buffer, &buffer_len TSRMLS_CC)) {
                RETURN_FALSE;
+       }       
+       if (buffer_len > 0) {
+               RETURN_STRINGL(buffer, buffer_len, 0);
+       }
+       else {
+               RETURN_EMPTY_STRING();
        }
-       RETURN_STRINGL(buffer, buffer_len, 0);
 }
 /* }}} */
 
index e1e343e15b5aa567fe1103d158ea82056127cf27..512607942e8828fa066cbfcbc048ba5ed17dc430 100644 (file)
@@ -160,6 +160,10 @@ int php_oci_lob_read (php_oci_descriptor *descriptor, long read_length, long off
        if (php_oci_lob_get_length(descriptor, &length TSRMLS_CC)) {
                return 1;
        }
+
+       if (length <= 0) {
+               return 0;
+       }
        
        if (offset > length) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Offset must be less than size of the LOB");