fix #33383 (crash when retrieving empty BLOBs)

This commit is contained in:
Antony Dovgal 2005-10-10 10:16:58 +00:00
parent 2d5f21c2fb
commit f15f20ffa2
3 changed files with 22 additions and 3 deletions

View 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 {

View 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);
}
/* }}} */

View 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");