Обсуждение: BUG: pgIndex.cpp

Поиск
Список
Период
Сортировка

BUG: pgIndex.cpp

От
P3 Consulting
Дата:
            switch (indexes->GetVal(wxT("contype"))[0U])
             {
                 case 0:
                     index = new pgIndex(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
                     break;
                 case 'p':
                     index = new pgPrimaryKey(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
                     break;
                 case 'u':
                     index = new pgUnique(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
                     break;
                 default:
                     index=0;
                     break;
             }
             index->iSetOid(indexes->GetOid(wxT("oid")));

in case of the default branch taken, this code will SIGSEGV

Pascal Pochet


Re: BUG: pgIndex.cpp

От
"Dave Page"
Дата:

> -----Original Message-----
> From: pgadmin-hackers-owner@postgresql.org
> [mailto:pgadmin-hackers-owner@postgresql.org] On Behalf Of P3
> Consulting
> Sent: 08 January 2005 10:28
> To: pgadmin-hackers
> Subject: [pgadmin-hackers] BUG: pgIndex.cpp
>
>             switch (indexes->GetVal(wxT("contype"))[0U])
>              {
>                  case 0:
>                      index = new pgIndex(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
>                      break;
>                  case 'p':
>                      index = new pgPrimaryKey(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
>                      break;
>                  case 'u':
>                      index = new pgUnique(collection->GetSchema(),
indexes->GetVal(wxT("idxname")));
>                      break;
>                  default:
>                      index=0;
>                      break;
>              }
>              index->iSetOid(indexes->GetOid(wxT("oid")));
>
> in case of the default branch taken, this code will SIGSEGV

Hi Andreas,

Did you get a chance to look at this? It seems to me that the quick and
dirty solution is to wrap the index->iSetxxx calls in an 'if (index)',
however I'm not entirely convinced that is safe given that it's possible
to return a null index pointer to the caller (which without significant
trawling through code I may not find all instances of).

Regards, Dave.

Re: BUG: pgIndex.cpp

От
Andreas Pflug
Дата:
Dave Page wrote:

> Did you get a chance to look at this? It seems to me that the quick and
> dirty solution is to wrap the index->iSetxxx calls in an 'if (index)',
> however I'm not entirely convinced that is safe given that it's possible
> to return a null index pointer to the caller (which without significant
> trawling through code I may not find all instances of).

I don't see the point catching this beyond an assert. A sane pgsql will
never return contype != p, u, or NULL unless system tables are corrupted.

Regards,
Andreas

Re: BUG: pgIndex.cpp

От
"Dave Page"
Дата:

> -----Original Message-----
> From: Andreas Pflug [mailto:pgadmin@pse-consulting.de]
> Sent: 12 January 2005 09:27
> To: Dave Page
> Cc: P3 Consulting; pgadmin-hackers
> Subject: Re: [pgadmin-hackers] BUG: pgIndex.cpp
>
> Dave Page wrote:
>
> > Did you get a chance to look at this? It seems to me that
> the quick and
> > dirty solution is to wrap the index->iSetxxx calls in an
> 'if (index)',
> > however I'm not entirely convinced that is safe given that
> it's possible
> > to return a null index pointer to the caller (which without
> significant
> > trawling through code I may not find all instances of).
>
> I don't see the point catching this beyond an assert. A sane
> pgsql will
> never return contype != p, u, or NULL unless system tables
> are corrupted.

Very true.

Regards, Dave.