Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 79aa445

Browse files
committed
Protect pg_stat_reset_shared() against NULL input
Per bug #6082, reported by Steve Haslam
1 parent 21f1e15 commit 79aa445

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/backend/utils/adt/pgstatfuncs.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,9 +1537,17 @@ pg_stat_reset(PG_FUNCTION_ARGS)
15371537
Datum
15381538
pg_stat_reset_shared(PG_FUNCTION_ARGS)
15391539
{
1540-
char *target = text_to_cstring(PG_GETARG_TEXT_PP(0));
1541-
1542-
pgstat_reset_shared_counters(target);
1540+
if (PG_ARGISNULL(0))
1541+
/*
1542+
* Same error message as in pgstat_reset_shared_counters(),
1543+
* to keep translations the same.
1544+
*/
1545+
ereport(ERROR,
1546+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1547+
errmsg("unrecognized reset target: \"%s\"", "null"),
1548+
errhint("Target must be \"bgwriter\".")));
1549+
1550+
pgstat_reset_shared_counters(text_to_cstring(PG_GETARG_TEXT_PP(0)));
15431551

15441552
PG_RETURN_VOID();
15451553
}

0 commit comments

Comments
 (0)