Opened 17 years ago

Last modified 17 years ago

#1357 closed defect (invalid)

Segfaults in OGRGenSQLResultsLayer

Reported by: dron Owned by: warmerdam
Priority: highest Milestone:
Component: default Version: unspecified
Severity: critical Keywords:
Cc:

Description

It seems there is a logical error in OGRGenSQLResultsLayer::PrepareSummary() and OGRGenSQLResultsLayer::GetFeature() methods. In PrepareSummary() we have a loop

    while( (poSrcFeature = poSrcLayer->GetNextFeature()) != NULL )
    {
        ...
        swq_select_summarize( psSelectInfo, iField, szBuffer);
        ...
    }

In my case this loop is never executed and psSelectInfo->column_summary is never initialized and stays NULL. But it is used later in the code (in the swq_select_finish_summarize() call and at the end of PrepareSummary() method) without checking. That is resulted in segmentation fault.

The same happens in GetFeature() method:

    if( psSelectInfo->query_mode == SWQM_DISTINCT_LIST )
    {
        ...
        swq_summary *psSummary = psSelectInfo->column_summary + 0;
        ...
    }

I have found this problem because gdalautotest failed on my box (ogr_sql_test.py, tests ogr_sql_11 and ogr_sql_12). I am not sure how to fix it in the right way, so I am filing this bug report instead of changing the code.

Best regards,
Andrey

Change History (3)

comment:1 by warmerdam, 17 years ago

Andrey,

This test was introduced to test a very recent fix in CVS.  Is it possible
that you haven't done a complete cvs update -d and rebuild recently?  It 
does work fine for me. 

You might also review Bug 1298.

comment:2 by dron, 17 years ago

Hmm, I am always do 'cvs update -Pd' and my ogr_gensql.cpp is marked as

$Id: ogr_gensql.cpp,v 1.18 2006/04/25 23:03:17 fwarmerdam Exp $

Is it possible that your change has not been actually commited in CVS?

comment:3 by dron, 17 years ago

Ok, that was my local problem (ogr_gensql.cpp was out of date). All works fine with the recent version.

Best regards,
Andrey
Note: See TracTickets for help on using tickets.