From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Mendola Gaetano <mendola(at)bigfoot(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SetVariable |
Date: | 2003-08-30 04:12:24 |
Message-ID: | 200308300412.h7U4COH22266@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Mendola Gaetano wrote:
> Hi all,
> I found this code on the file variables.c and
> in the function SetVariable I read:
>
> if (strcmp(current->name, name) == 0)
> {
> free(current->value);
> current->value = strdup(value);
> return current->value ? true : false;
> }
>
> this mean that if there is no memory left on the
> sistem we loose the old value,
> if this is not the indeended behaviour may be is better do:
I see other strdup() calls that don't check on a return. Should we deal
with those too?
>
> if (strcmp(current->name, name) == 0)
> {
> char * tmp_value = strdup(value);
>
> if ( !tmp_value )
> {
> return false;
> }
>
> free(current->value);
> current->value = tmp_value;
>
> return true;
> }
>
>
> Regards
> Gaetano Mendola
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Larry Rosenman | 2003-08-30 04:13:40 | Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...) |
Previous Message | Marc G. Fournier | 2003-08-30 04:09:54 | Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...) |