Re: SetVariable - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: SetVariable
Date
Msg-id 200308300412.h7U4COH22266@candle.pha.pa.us
Whole thread Raw
In response to SetVariable  ("Mendola Gaetano" <mendola@bigfoot.com>)
List 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@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...)
Next
From: Larry Rosenman
Date:
Subject: Re: Unixware Patch (Was: Re: Beta2 Tag'd and Bundled ...)