Re: BUG #15838: [contrib] vacuumlo: schema variable checked for NULLthree times

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: BUG #15838: [contrib] vacuumlo: schema variable checked for NULLthree times
Дата
Msg-id df739c70-a17a-7d97-a621-ab61dbf03a8f@iki.fi
обсуждение исходный текст
Ответ на BUG #15838: [contrib] vacuumlo: schema variable checked for NULL three times  (PG Bug reporting form <noreply@postgresql.org>)
Ответы Re: BUG #15838: [contrib] vacuumlo: schema variable checked for NULL three times  (Timur Birsh <taem@linukz.org>)
Список pgsql-bugs
On 07/06/2019 09:15, PG Bug reporting form wrote:
> vacuumlo() has this (starting on line 239):
> 
>                  if (!schema || !table || !field)
>                  {
>                          fprintf(stderr, "%s", PQerrorMessage(conn));
>                          PQclear(res);
>                          PQfinish(conn);
>                          if (schema != NULL)
>                                  PQfreemem(schema);
>                          if (schema != NULL)
>                                  PQfreemem(table);
>                          if (schema != NULL)
>                                  PQfreemem(field);
>                          return -1;
>                  }
> 
> I think this can be replaced with this:
> 
>                  if (!schema || !table || !field)
>                  {
>                          fprintf(stderr, "%s", PQerrorMessage(conn));
>                          PQclear(res);
>                          PQfinish(conn);
>                          if (schema != NULL) {
>                                  PQfreemem(schema);
>                                  PQfreemem(table);
>                                  PQfreemem(field);
>                          }
>                          return -1;
>                  }

Hmm. Currently, if allocating 'schema' fails, but allocating 'table' or 
'field' succeeds, you leak memory. I'm pretty sure that was intended to be:

         if (!schema || !table || !field)
         {
             fprintf(stderr, "%s", PQerrorMessage(conn));
             PQclear(res);
             PQfinish(conn);
             if (schema != NULL)
                 PQfreemem(schema);
             if (table != NULL)
                 PQfreemem(table);
             if (field != NULL)
                 PQfreemem(field);
             return -1;
         }

I'll go fix it that way, thanks for the report!

- Heikki



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Sasa Vilic
Дата:
Сообщение: Unable to create postgis extension on CentOS7 when using pg11 andnewest postgis 2.5 (postgis25_11-2.5.2-2.rhel7.x86_64) due to undefinedsymbol OGR_GT_Flatten
Следующее
От: Timur Birsh
Дата:
Сообщение: Re: BUG #15838: [contrib] vacuumlo: schema variable checked for NULL three times