Skip to content

Commit c153d88

Browse files
committed
clobber some string shims
1 parent 96460a4 commit c153d88

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

ibm_db2.c

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ ZEND_DECLARE_MODULE_GLOBALS(ibm_db2)
3939

4040
#define ZEND_Z_STRVAL_PP(data) Z_STRVAL_P(*data)
4141

42-
#define ZEND_RETVAL_STRINGL(str, len, dup) RETVAL_STRINGL(str, len)
43-
44-
#define ZEND_RETVAL_STRING(str, val) RETVAL_STRING(str)
45-
4642
#define ZEND_FETCH_RESOURCE_NEW(res, stmt_type, stmt, stmt_id, resource_type_name, le_stmt)\
4743
res = (stmt_type) zend_fetch_resource(Z_RES_P(*stmt),resource_type_name,le_stmt);\
4844
if(res == NULL)\
@@ -56,17 +52,11 @@ rsrc = (rsrc_type) zend_fetch_resource2(Z_RES_P(*passed_id),resource_type_name,r
5652
if(rsrc == NULL)\
5753
RETURN_FALSE;
5854

59-
#define ZEND_RETURN_STRINGL(str,len,val) RETURN_STRINGL(str, len)
60-
61-
#define ZEND_RETURN_STRING_NOFREE(str,val) RETURN_STRING(str)
62-
6355
#define ZEND_RETURN_STRING(str,val) \
6456
RETVAL_STRING(str); \
6557
efree(str);\
6658
return
6759

68-
#define ZEND_STR(data) Z_STR_P(data)
69-
7060
#define ZEND_ZVAL_PTR_DTOR(data) zval_ptr_dtor(data)
7161

7262
#define IBM_DB2_ZEND_GET_TYPE(data) (data)->u1.v.type
@@ -4694,7 +4684,7 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
46944684
* each string (or atom) is allocated once and never changed (immutable)
46954685
* aka, not useful for INOUT and OUT parameters obviously
46964686
*/
4697-
if (IS_INTERNED(ZEND_STR(*data))) {
4687+
if (IS_INTERNED(Z_STR_P(*data))) {
46984688
/* Need use macro assignment to avoid leak in php 7. (Thanks Dimitry)
46994689
* Z_STR_P(*data) = zend_string_init(ZEND_Z_STRVAL_PP(data), ZEND_Z_STRLEN_PP(data), 0);
47004690
*/
@@ -5144,9 +5134,9 @@ static void _free_param_cache_list(stmt_handle *stmt_res) {
51445134
/* Free Values */
51455135
if (prev_ptr->value != NULL) {
51465136
if ( ZEND_Z_TYPE_P(prev_ptr->value) == IS_STRING ) {
5147-
if((ZEND_STR(prev_ptr->value)) != NULL || Z_STRLEN_P(prev_ptr->value) != 0) {
5148-
if (!IS_INTERNED((ZEND_STR(prev_ptr->value)))) {
5149-
zend_string_release((ZEND_STR(prev_ptr->value)));
5137+
if((Z_STR_P(prev_ptr->value)) != NULL || Z_STRLEN_P(prev_ptr->value) != 0) {
5138+
if (!IS_INTERNED((Z_STR_P(prev_ptr->value)))) {
5139+
zend_string_release((Z_STR_P(prev_ptr->value)));
51505140
}
51515141
}
51525142
}
@@ -5412,7 +5402,7 @@ PHP_FUNCTION(db2_conn_errormsg)
54125402

54135403
ZEND_RETURN_STRING(return_str, 0);
54145404
} else {
5415-
ZEND_RETURN_STRING_NOFREE(IBM_DB2_G(__php_conn_err_msg), 1);
5405+
RETURN_STRING(IBM_DB2_G(__php_conn_err_msg));
54165406
}
54175407
}
54185408
/* }}} */
@@ -5434,7 +5424,7 @@ PHP_FUNCTION(db2_stmt_errormsg)
54345424
if (stmt) {
54355425
ZEND_FETCH_RESOURCE_NEW(stmt_res, stmt_handle*, &stmt, stmt_id, "Statement Resource", le_stmt_struct);
54365426
if ( stmt_res->exec_many_err_msg != NULL ) {
5437-
ZEND_RETURN_STRING_NOFREE(stmt_res->exec_many_err_msg, 1);
5427+
RETURN_STRING(stmt_res->exec_many_err_msg);
54385428
}
54395429

54405430
return_str = (char*)ecalloc(1, DB2_MAX_ERR_MSG_LEN);
@@ -5445,7 +5435,7 @@ PHP_FUNCTION(db2_stmt_errormsg)
54455435

54465436
ZEND_RETURN_STRING(return_str, 0);
54475437
} else {
5448-
ZEND_RETURN_STRING_NOFREE(IBM_DB2_G(__php_stmt_err_msg), 1);
5438+
RETURN_STRING(IBM_DB2_G(__php_stmt_err_msg));
54495439
}
54505440
}
54515441
/* }}} */
@@ -5478,7 +5468,7 @@ PHP_FUNCTION(db2_conn_error)
54785468

54795469
ZEND_RETURN_STRING(return_str, 0);
54805470
} else {
5481-
ZEND_RETURN_STRING_NOFREE(IBM_DB2_G(__php_conn_err_state), 1);
5471+
RETURN_STRING(IBM_DB2_G(__php_conn_err_state));
54825472
}
54835473
}
54845474
/* }}} */
@@ -5511,7 +5501,7 @@ PHP_FUNCTION(db2_stmt_error)
55115501

55125502
ZEND_RETURN_STRING(return_str, 0);
55135503
} else {
5514-
ZEND_RETURN_STRING_NOFREE(IBM_DB2_G(__php_stmt_err_state), 1);
5504+
RETURN_STRING(IBM_DB2_G(__php_stmt_err_state));
55155505
}
55165506
}
55175507
/* }}} */
@@ -5700,7 +5690,7 @@ PHP_FUNCTION(db2_field_name)
57005690
if ( col < 0 ) {
57015691
RETURN_FALSE;
57025692
}
5703-
ZEND_RETURN_STRING_NOFREE((char *)stmt_res->column_info[col].name,1);
5693+
RETURN_STRING((char *)stmt_res->column_info[col].name);
57045694
}
57055695
/* }}} */
57065696

@@ -5920,7 +5910,7 @@ PHP_FUNCTION(db2_field_type)
59205910
str_val = "string";
59215911
break;
59225912
}
5923-
ZEND_RETURN_STRING_NOFREE(str_val, 1);
5913+
RETURN_STRING(str_val);
59245914
}
59255915
/* }}} */
59265916

@@ -6249,7 +6239,7 @@ PHP_FUNCTION(db2_result)
62496239
efree(out_ptr);
62506240
RETURN_NULL();
62516241
} else {
6252-
ZEND_RETVAL_STRING((char*)out_ptr, 1);
6242+
RETVAL_STRING((char*)out_ptr);
62536243
efree(out_ptr);
62546244
}
62556245
break;
@@ -6319,7 +6309,7 @@ PHP_FUNCTION(db2_result)
63196309
if (rc == SQL_ERROR) {
63206310
RETURN_FALSE;
63216311
}
6322-
ZEND_RETURN_STRINGL(out_char_ptr, out_length, 0);
6312+
RETURN_STRINGL(out_char_ptr, out_length);
63236313
break;
63246314
case SQL_BLOB:
63256315
case SQL_BINARY:
@@ -6381,7 +6371,7 @@ PHP_FUNCTION(db2_result)
63816371
if (rc == SQL_ERROR) {
63826372
RETURN_FALSE;
63836373
}
6384-
ZEND_RETVAL_STRINGL((char*)out_ptr,out_length, 0);
6374+
RETVAL_STRINGL((char*)out_ptr,out_length);
63856375
default:
63866376
break;
63876377
}
@@ -6413,7 +6403,7 @@ PHP_FUNCTION(db2_result)
64136403
if (out_length == SQL_NULL_DATA) {
64146404
RETURN_NULL();
64156405
}
6416-
ZEND_RETVAL_STRINGL((char*)out_char_ptr,out_length, 0);
6406+
RETVAL_STRINGL((char*)out_char_ptr,out_length);
64176407
#else /* not PASE */
64186408
rc = _php_db2_get_data(stmt_res, col_num+1, SQL_C_BINARY, NULL, 0, (SQLINTEGER *)&in_length);
64196409
if ( rc == SQL_ERROR ) {
@@ -6431,7 +6421,7 @@ PHP_FUNCTION(db2_result)
64316421
if (rc == SQL_ERROR) {
64326422
RETURN_FALSE;
64336423
}
6434-
ZEND_RETVAL_STRINGL((char*)out_ptr,out_length, 0);
6424+
RETVAL_STRINGL((char*)out_ptr,out_length);
64356425
#endif /* not PASE */
64366426
break;
64376427

@@ -7573,7 +7563,7 @@ PHP_FUNCTION(db2_escape_string)
75737563
/* reallocate to the real length */
75747564
new_str = (char *)realloc(new_str, new_length + 1);
75757565

7576-
ZEND_RETURN_STRINGL(new_str, new_length, 1);
7566+
RETURN_STRINGL(new_str, new_length);
75777567
}
75787568
/* }}} */
75797569

@@ -7623,7 +7613,7 @@ PHP_FUNCTION(db2_lob_read)
76237613
RETURN_FALSE;
76247614
}
76257615

7626-
ZEND_RETVAL_STRING((char*)out_ptr, 1);
7616+
RETVAL_STRING((char*)out_ptr);
76277617
efree(out_ptr);
76287618
}
76297619
/* }}} */
@@ -7710,7 +7700,7 @@ PHP_FUNCTION(db2_get_option)
77107700
php_error_docref(NULL, E_WARNING, "Incorrect option string passed in");
77117701
RETURN_FALSE;
77127702
}
7713-
ZEND_RETURN_STRINGL(value, val_len, 0);
7703+
RETURN_STRINGL(value, val_len);
77147704
} else {
77157705
php_error_docref(NULL, E_WARNING, "Supplied parameter is invalid");
77167706
RETURN_FALSE;

0 commit comments

Comments
 (0)