Skip to content

Commit e98ddc9

Browse files
committed
fix
anonymous function has not set hashkey, and then should not be searched in plpgsql_check_HashTable. Anonymous block should be always marked as unchecked. Fix crash #175
1 parent 43bfbe5 commit e98ddc9

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

expected/plpgsql_check_passive.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,9 @@ end;
353353
$$ language plpgsql;
354354
call proc_test();
355355
drop procedure proc_test();
356+
-- should not to crash
357+
set plpgsql_check.mode = 'fresh_start';
358+
do $$
359+
begin
360+
end;
361+
$$;

expected/plpgsql_check_passive_1.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,9 @@ end;
350350
$$ language plpgsql;
351351
call proc_test();
352352
drop procedure proc_test();
353+
-- should not to crash
354+
set plpgsql_check.mode = 'fresh_start';
355+
do $$
356+
begin
357+
end;
358+
$$;

sql/plpgsql_check_passive.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,10 @@ $$ language plpgsql;
325325
call proc_test();
326326

327327
drop procedure proc_test();
328+
329+
-- should not to crash
330+
set plpgsql_check.mode = 'fresh_start';
331+
do $$
332+
begin
333+
end;
334+
$$;

src/check_function.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,9 @@ plpgsql_check_is_checked(PLpgSQL_function *func)
13751375
{
13761376
plpgsql_check_HashEnt *hentry;
13771377

1378+
if (!func->fn_hashkey)
1379+
return false;
1380+
13781381
hentry = (plpgsql_check_HashEnt *) hash_search(plpgsql_check_HashTable,
13791382
(void *) func->fn_hashkey,
13801383
HASH_FIND,

0 commit comments

Comments
 (0)