Skip to content

Commit 6041885

Browse files
committed
Fix truncation issue with single character when trim is enabled
Also fix inconsistent indentation. Because the indentation change ruins the diff, you're looking at the condition for the for clause.
1 parent fe6f0ff commit 6041885

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

ibm_db2.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6238,26 +6238,26 @@ static void _php_db2_bind_fetch_helper(INTERNAL_FUNCTION_PARAMETERS, int op)
62386238
case SQL_NUMERIC:
62396239
case SQL_DECFLOAT:
62406240
#ifdef PASE /* i5/OS trim spaces */
6241-
if (stmt_res->s_i5_conn_parent->c_i5_char_trim > 0) {
6242-
i5trim = strlen((char *)row_data->str_val);
6243-
for(; i5trim; i5trim--) {
6244-
i5char = (char)(((char *)row_data->str_val)[i5trim]);
6245-
if (i5char == 0x00 || i5char == 0x20) {
6246-
continue;
6247-
}
6248-
i5trim++;
6249-
break;
6250-
}
6251-
if ( op & DB2_FETCH_ASSOC ) {
6252-
add_assoc_stringl(return_value, (char *)stmt_res->column_info[i].name,
6253-
(char *)row_data->str_val, i5trim);
6254-
}
6255-
if ( op & DB2_FETCH_INDEX ) {
6256-
add_index_stringl(return_value, i, (char *)row_data->str_val,
6257-
i5trim);
6258-
}
6259-
break;
6260-
}
6241+
if (stmt_res->s_i5_conn_parent->c_i5_char_trim > 0) {
6242+
i5trim = strlen((char *)row_data->str_val);
6243+
for(; i5trim >= 0; i5trim--) {
6244+
i5char = (char)(((char *)row_data->str_val)[i5trim]);
6245+
if (i5char == 0x00 || i5char == 0x20) {
6246+
continue;
6247+
}
6248+
i5trim++;
6249+
break;
6250+
}
6251+
if ( op & DB2_FETCH_ASSOC ) {
6252+
add_assoc_stringl(return_value, (char *)stmt_res->column_info[i].name,
6253+
(char *)row_data->str_val, i5trim);
6254+
}
6255+
if ( op & DB2_FETCH_INDEX ) {
6256+
add_index_stringl(return_value, i, (char *)row_data->str_val,
6257+
i5trim);
6258+
}
6259+
break;
6260+
}
62616261
#endif /* PASE */
62626262
if ( op & DB2_FETCH_ASSOC ) {
62636263
add_assoc_stringl(return_value, (char *)stmt_res->column_info[i].name,

0 commit comments

Comments
 (0)