Skip to content

Commit 920c506

Browse files
committed
SetPGVariable() crashed on SET DateStyle TO DEFAULT and related cases.
1 parent d354370 commit 920c506

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/backend/commands/variable.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.40 2000/08/01 18:29:29 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.41 2000/09/22 15:34:31 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -592,28 +592,33 @@ reset_random_seed(void)
592592
void
593593
SetPGVariable(const char *name, const char *value)
594594
{
595+
char *mvalue = value ? pstrdup(value) : ((char*) NULL);
596+
595597
/*
596598
* Special cases ought to be removed and handled separately
597599
* by TCOP
598600
*/
599601
if (strcasecmp(name, "datestyle")==0)
600-
parse_date(pstrdup(value));
602+
parse_date(mvalue);
601603
else if (strcasecmp(name, "timezone")==0)
602-
parse_timezone(pstrdup(value));
604+
parse_timezone(mvalue);
603605
else if (strcasecmp(name, "DefaultXactIsoLevel")==0)
604-
parse_DefaultXactIsoLevel(pstrdup(value));
606+
parse_DefaultXactIsoLevel(mvalue);
605607
else if (strcasecmp(name, "XactIsoLevel")==0)
606-
parse_XactIsoLevel(pstrdup(value));
608+
parse_XactIsoLevel(mvalue);
607609
#ifdef MULTIBYTE
608610
else if (strcasecmp(name, "client_encoding")==0)
609-
parse_client_encoding(pstrdup(value));
611+
parse_client_encoding(mvalue);
610612
else if (strcasecmp(name, "server_encoding")==0)
611-
parse_server_encoding(pstrdup(value));
613+
parse_server_encoding(mvalue);
612614
#endif
613615
else if (strcasecmp(name, "random_seed")==0)
614-
parse_random_seed(pstrdup(value));
616+
parse_random_seed(mvalue);
615617
else
616618
SetConfigOption(name, value, superuser() ? PGC_SUSET : PGC_USERSET);
619+
620+
if (mvalue)
621+
pfree(mvalue);
617622
}
618623

619624

0 commit comments

Comments
 (0)