Opened 14 years ago

Closed 14 years ago

#3727 closed defect (fixed)

OGR SQL engine: memory leaks on invalid expressions

Reported by: Even Rouault Owned by: Even Rouault
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords: rfc28
Cc:

Description

$ valgrind --leak-check=full ogrinfo ../autotest/ogr/data -sql "select 1 +"

==8887== Memcheck, a memory error detector
==8887== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==8887== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==8887== Command: ogrinfo ../autotest/ogr/data -sql select\ 1\ +
==8887== 
INFO: Open of `../autotest/ogr/data'
      using driver `ESRI Shapefile' successful.
ERROR 1: SQL Expression Parsing Error: syntax error
==8887== 
==8887== HEAP SUMMARY:
==8887==     in use at exit: 264 bytes in 6 blocks
==8887==   total heap usage: 25,341 allocs, 25,335 frees, 1,911,398 bytes allocated
==8887== 
==8887== 64 bytes in 1 blocks are definitely lost in loss record 6 of 6
==8887==    at 0x4C28CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==8887==    by 0x58DAC4A: swqlex(swq_expr_node**, swq_parse_context*) (swq.cpp:151)
==8887==    by 0x58DEA77: swqparse(swq_parse_context*) (swq_parser.cpp:1470)
==8887==    by 0x58E178A: swq_select::preparse(char const*) (swq_select.cpp:152)
==8887==    by 0x574DB89: OGRDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrdatasource.cpp:764)
==8887==    by 0x581A7D9: OGRShapeDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrshapedatasource.cpp:708)
==8887==    by 0x402A07: main (ogrinfo.cpp:236)
==8887== 
==8887== LEAK SUMMARY:
==8887==    definitely lost: 64 bytes in 1 blocks
==8887==    indirectly lost: 0 bytes in 0 blocks
==8887==      possibly lost: 0 bytes in 0 blocks
==8887==    still reachable: 200 bytes in 5 blocks
==8887==         suppressed: 0 bytes in 0 blocks
==8887== Reachable blocks (those to which a pointer was found) are not shown.

$ valgrind --leak-check=full ogrinfo ../autotest/ogr/data -sql "select count(1"

==8869== Memcheck, a memory error detector
==8869== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==8869== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==8869== Command: ogrinfo ../autotest/ogr/data -sql select\ count(1
==8869==
INFO: Open of `../autotest/ogr/data'
      using driver `ESRI Shapefile' successful.
ERROR 1: SQL Expression Parsing Error: syntax error
==8869==
==8869== HEAP SUMMARY:
==8869==     in use at exit: 438 bytes in 10 blocks
==8869==   total heap usage: 25,349 allocs, 25,339 frees, 1,911,691 bytes allocated
==8869==
==8869== 86 (64 direct, 22 indirect) bytes in 1 blocks are definitely lost in loss record 9 of 10
==8869==    at 0x4C28CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==8869==    by 0x58DB16E: swqlex(swq_expr_node**, swq_parse_context*) (swq.cpp:219)
==8869==    by 0x58DEA77: swqparse(swq_parse_context*) (swq_parser.cpp:1470)
==8869==    by 0x58E178A: swq_select::preparse(char const*) (swq_select.cpp:152)
==8869==    by 0x574DB89: OGRDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrdatasource.cpp:764)
==8869==    by 0x581A7D9: OGRShapeDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrshapedatasource.cpp:708)
==8869==    by 0x402A07: main (ogrinfo.cpp:236)
==8869==
==8869== 152 (64 direct, 88 indirect) bytes in 1 blocks are definitely lost in loss record 10 of 10
==8869==    at 0x4C28CC1: operator new(unsigned long) (vg_replace_malloc.c:261)
==8869==    by 0x58DF69E: swqparse(swq_parse_context*) (swq_parser.y:273)
==8869==    by 0x58E178A: swq_select::preparse(char const*) (swq_select.cpp:152)
==8869==    by 0x574DB89: OGRDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrdatasource.cpp:764)
==8869==    by 0x581A7D9: OGRShapeDataSource::ExecuteSQL(char const*, OGRGeometry*, char const*) (ogrshapedatasource.cpp:708)
==8869==    by 0x402A07: main (ogrinfo.cpp:236)
==8869==
==8869== LEAK SUMMARY:
==8869==    definitely lost: 128 bytes in 2 blocks
==8869==    indirectly lost: 110 bytes in 3 blocks
==8869==      possibly lost: 0 bytes in 0 blocks
==8869==    still reachable: 200 bytes in 5 blocks
==8869==         suppressed: 0 bytes in 0 blocks

Change History (2)

comment:1 by Even Rouault, 14 years ago

Owner: changed from warmerdam to Even Rouault

comment:2 by Even Rouault, 14 years ago

Resolution: fixed
Status: newclosed
Version: unspecifiedsvn-trunk

r20381 /trunk/gdal/ogr/ (swq_parser.cpp swq_parser.y swq_select.cpp): SQL engine: fix memory leaks in error cases; also fix crash in expression 'field_name NOT IN (value1, ...)' (#3727)

r20382 /trunk/autotest/ogr/ (ogr_sql_rfc28.py ogr_sql_test.py): SQL engine: more testing of errors; test expression 'field_name NOT IN (value1, ...)' (#3727)

Note: See TracTickets for help on using tickets.