Skip to content

Commit f85e3ff

Browse files
committed
Modify the string only if it's been successfully allocated
1 parent 23d48e9 commit f85e3ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ibm_db2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6016,11 +6016,11 @@ PHP_FUNCTION(db2_result)
60166016
RETURN_NULL();
60176017
}
60186018
out_char_ptr = (SQLPOINTER)ecalloc(1, in_length+2);
6019-
out_char_ptr[in_length+1] = '\0';
60206019
if ( out_char_ptr == NULL ) {
60216020
php_error_docref(NULL, E_WARNING, "Cannot Allocate Memory");
60226021
RETURN_FALSE;
60236022
}
6023+
out_char_ptr[in_length+1] = '\0';
60246024
rc = _php_db2_get_data(stmt_res, col_num+1, lob_bind_type, out_char_ptr+1, in_length, &out_length);
60256025
out_char_ptr[0] = i5oshack;
60266026
if ( rc == SQL_ERROR ) {

0 commit comments

Comments
 (0)