8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Better handle null pointer checks in GPRE generated code

This commit is contained in:
Artyom Abakumov 2024-12-18 10:49:00 +03:00 committed by Adriano dos Santos Fernandes
parent d1f8afd885
commit 2528942a8c

View File

@ -2293,7 +2293,10 @@ static void gen_for( const act* action, int column)
const gpre_req* request = action->act_request; const gpre_req* request = action->act_request;
if (action->act_error || (action->act_flags & ACT_sql)) if (action->act_error || (action->act_flags & ACT_sql))
success(column, true, global_status_name, " {"); {
printa(column, "if (%s && !(%s->getState() & Firebird::IStatus::STATE_ERRORS)) {",
request->req_handle, global_status_name);
}
printa(column, "while (1)"); printa(column, "while (1)");
column += INDENT; column += INDENT;
@ -3075,11 +3078,10 @@ static void gen_s_start( const act* action, int column)
if (action->act_error || (action->act_flags & ACT_sql)) if (action->act_error || (action->act_flags & ACT_sql))
{ {
make_ok_test(action, request, column); make_ok_test(action, request, column);
printa(column, "{");
column += INDENT; column += INDENT;
} }
gen_start(action, port, column, false); gen_start(action, port, column, false);
if (action->act_error || (action->act_flags & ACT_sql))
column -= INDENT;
const TEXT* pattern1 = "if (%V1->getErrors()[1] == isc_bad_req_handle) { %RH->release(); %RH = NULL; }"; const TEXT* pattern1 = "if (%V1->getErrors()[1] == isc_bad_req_handle) { %RH->release(); %RH = NULL; }";
PAT args; PAT args;
@ -3088,6 +3090,12 @@ static void gen_s_start( const act* action, int column)
PATTERN_expand((USHORT) column, pattern1, &args); PATTERN_expand((USHORT) column, pattern1, &args);
printa(column, "else break;"); printa(column, "else break;");
if (action->act_error || (action->act_flags & ACT_sql))
{
column -= INDENT;
printa(column, "}");
}
if (action->act_type == ACT_open) if (action->act_type == ACT_open)
{ {
endp(column); endp(column);