Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MiraMonVector: Fixing chromium bug 68809 #9954

Conversation

AbelPau
Copy link
Contributor

@AbelPau AbelPau commented May 16, 2024

What does this PR do?

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809
A copy of a pointer was freed instead of the pointer.

What are related issues/pull requests?

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809

Tasklist

A copy of a pointer was freed instead the pointer.
@rouault
Copy link
Member

rouault commented May 16, 2024

thanks!

@rouault rouault merged commit c31cbe0 into OSGeo:master May 16, 2024
32 of 35 checks passed
@rouault
Copy link
Member

rouault commented May 18, 2024

@AbelPau This PR doesn't fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809. I can still reproduce the leak with latest master including this merged pull request:

$ valgrind --leak-check=full fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720 
==2045802== Memcheck, a memory error detector
==2045802== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2045802== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==2045802== Command: fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720
==2045802== 
==2045802== 
==2045802== HEAP SUMMARY:
==2045802==     in use at exit: 708,976 bytes in 5,464 blocks
==2045802==   total heap usage: 10,934 allocs, 5,470 frees, 1,873,812 bytes allocated
==2045802== 
==2045802== 16,129 (2,128 direct, 14,001 indirect) bytes in 1 blocks are definitely lost in loss record 5,459 of 5,461
==2045802==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==2045802==    by 0x50AEC28: VSICalloc (cpl_vsisimple.cpp:454)
==2045802==    by 0x5EB8FD9: MM_CreateEmptyHeader (mm_gdal_functions.c:243)
==2045802==    by 0x5EB905A: MM_CreateDBFHeader (mm_gdal_functions.c:271)
==2045802==    by 0x5EB611F: MMCreateMMDB (mm_wrlayr.c:6355)
==2045802==    by 0x5EB17C8: MMCreateRecordDBF (mm_wrlayr.c:4411)
==2045802==    by 0x5EB207B: MMAddFeature (mm_wrlayr.c:4712)
==2045802==    by 0x5EA45DA: OGRMiraMonLayer::MMWriteGeometry() (ogrmiramonlayer.cpp:1938)
==2045802==    by 0x5EA3B86: OGRMiraMonLayer::MMProcessGeometry(OGRGeometryHS*, OGRFeature*, char) (ogrmiramonlayer.cpp:1694)
==2045802==    by 0x5EA3C2D: OGRMiraMonLayer::ICreateFeature(OGRFeature*) (ogrmiramonlayer.cpp:1723)
==2045802==    by 0x610C3C6: OGRLayer::CreateFeature(OGRFeature*) (ogrlayer.cpp:786)
==2045802==    by 0x63DA76A: LayerTranslator::Translate(OGRFeature*, TargetLayerInfo*, long long, long long*, long long&, int (*)(double, char const*, void*), void*, GDALVectorTranslateOptions const*) (ogr2ogr_lib.cpp:6466)

@AbelPau
Copy link
Contributor Author

AbelPau commented May 18, 2024

@AbelPau This PR doesn't fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809. I can still reproduce the leak with latest master including this merged pull request:

$ valgrind --leak-check=full fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720 
==2045802== Memcheck, a memory error detector
==2045802== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2045802== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==2045802== Command: fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720
==2045802== 
==2045802== 
==2045802== HEAP SUMMARY:
==2045802==     in use at exit: 708,976 bytes in 5,464 blocks
==2045802==   total heap usage: 10,934 allocs, 5,470 frees, 1,873,812 bytes allocated
==2045802== 
==2045802== 16,129 (2,128 direct, 14,001 indirect) bytes in 1 blocks are definitely lost in loss record 5,459 of 5,461
==2045802==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==2045802==    by 0x50AEC28: VSICalloc (cpl_vsisimple.cpp:454)
==2045802==    by 0x5EB8FD9: MM_CreateEmptyHeader (mm_gdal_functions.c:243)
==2045802==    by 0x5EB905A: MM_CreateDBFHeader (mm_gdal_functions.c:271)
==2045802==    by 0x5EB611F: MMCreateMMDB (mm_wrlayr.c:6355)
==2045802==    by 0x5EB17C8: MMCreateRecordDBF (mm_wrlayr.c:4411)
==2045802==    by 0x5EB207B: MMAddFeature (mm_wrlayr.c:4712)
==2045802==    by 0x5EA45DA: OGRMiraMonLayer::MMWriteGeometry() (ogrmiramonlayer.cpp:1938)
==2045802==    by 0x5EA3B86: OGRMiraMonLayer::MMProcessGeometry(OGRGeometryHS*, OGRFeature*, char) (ogrmiramonlayer.cpp:1694)
==2045802==    by 0x5EA3C2D: OGRMiraMonLayer::ICreateFeature(OGRFeature*) (ogrmiramonlayer.cpp:1723)
==2045802==    by 0x610C3C6: OGRLayer::CreateFeature(OGRFeature*) (ogrlayer.cpp:786)
==2045802==    by 0x63DA76A: LayerTranslator::Translate(OGRFeature*, TargetLayerInfo*, long long, long long*, long long&, int (*)(double, char const*, void*), void*, GDALVectorTranslateOptions const*) (ogr2ogr_lib.cpp:6466)

Oh, ok. Then I'll take another look on Monday.

@AbelPau
Copy link
Contributor Author

AbelPau commented May 20, 2024

@AbelPau This PR doesn't fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809. I can still reproduce the leak with latest master including this merged pull request:

$ valgrind --leak-check=full fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720 
==2045802== Memcheck, a memory error detector
==2045802== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2045802== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==2045802== Command: fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720
==2045802== 
==2045802== 
==2045802== HEAP SUMMARY:
==2045802==     in use at exit: 708,976 bytes in 5,464 blocks
==2045802==   total heap usage: 10,934 allocs, 5,470 frees, 1,873,812 bytes allocated
==2045802== 
==2045802== 16,129 (2,128 direct, 14,001 indirect) bytes in 1 blocks are definitely lost in loss record 5,459 of 5,461
==2045802==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==2045802==    by 0x50AEC28: VSICalloc (cpl_vsisimple.cpp:454)
==2045802==    by 0x5EB8FD9: MM_CreateEmptyHeader (mm_gdal_functions.c:243)
==2045802==    by 0x5EB905A: MM_CreateDBFHeader (mm_gdal_functions.c:271)
==2045802==    by 0x5EB611F: MMCreateMMDB (mm_wrlayr.c:6355)
==2045802==    by 0x5EB17C8: MMCreateRecordDBF (mm_wrlayr.c:4411)
==2045802==    by 0x5EB207B: MMAddFeature (mm_wrlayr.c:4712)
==2045802==    by 0x5EA45DA: OGRMiraMonLayer::MMWriteGeometry() (ogrmiramonlayer.cpp:1938)
==2045802==    by 0x5EA3B86: OGRMiraMonLayer::MMProcessGeometry(OGRGeometryHS*, OGRFeature*, char) (ogrmiramonlayer.cpp:1694)
==2045802==    by 0x5EA3C2D: OGRMiraMonLayer::ICreateFeature(OGRFeature*) (ogrmiramonlayer.cpp:1723)
==2045802==    by 0x610C3C6: OGRLayer::CreateFeature(OGRFeature*) (ogrlayer.cpp:786)
==2045802==    by 0x63DA76A: LayerTranslator::Translate(OGRFeature*, TargetLayerInfo*, long long, long long*, long long&, int (*)(double, char const*, void*), void*, GDALVectorTranslateOptions const*) (ogr2ogr_lib.cpp:6466)

@AbelPau This PR doesn't fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=68809. I can still reproduce the leak with latest master including this merged pull request:

$ valgrind --leak-check=full fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720 
==2045802== Memcheck, a memory error detector
==2045802== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2045802== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==2045802== Command: fuzzers/gdal_vector_translate_fuzzer clusterfuzz-testcase-minimized-gdal_vector_translate_fuzzer-6575332009246720
==2045802== 
==2045802== 
==2045802== HEAP SUMMARY:
==2045802==     in use at exit: 708,976 bytes in 5,464 blocks
==2045802==   total heap usage: 10,934 allocs, 5,470 frees, 1,873,812 bytes allocated
==2045802== 
==2045802== 16,129 (2,128 direct, 14,001 indirect) bytes in 1 blocks are definitely lost in loss record 5,459 of 5,461
==2045802==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==2045802==    by 0x50AEC28: VSICalloc (cpl_vsisimple.cpp:454)
==2045802==    by 0x5EB8FD9: MM_CreateEmptyHeader (mm_gdal_functions.c:243)
==2045802==    by 0x5EB905A: MM_CreateDBFHeader (mm_gdal_functions.c:271)
==2045802==    by 0x5EB611F: MMCreateMMDB (mm_wrlayr.c:6355)
==2045802==    by 0x5EB17C8: MMCreateRecordDBF (mm_wrlayr.c:4411)
==2045802==    by 0x5EB207B: MMAddFeature (mm_wrlayr.c:4712)
==2045802==    by 0x5EA45DA: OGRMiraMonLayer::MMWriteGeometry() (ogrmiramonlayer.cpp:1938)
==2045802==    by 0x5EA3B86: OGRMiraMonLayer::MMProcessGeometry(OGRGeometryHS*, OGRFeature*, char) (ogrmiramonlayer.cpp:1694)
==2045802==    by 0x5EA3C2D: OGRMiraMonLayer::ICreateFeature(OGRFeature*) (ogrmiramonlayer.cpp:1723)
==2045802==    by 0x610C3C6: OGRLayer::CreateFeature(OGRFeature*) (ogrlayer.cpp:786)
==2045802==    by 0x63DA76A: LayerTranslator::Translate(OGRFeature*, TargetLayerInfo*, long long, long long*, long long&, int (*)(double, char const*, void*), void*, GDALVectorTranslateOptions const*) (ogr2ogr_lib.cpp:6466)

@rouault I've fixed it here: #9966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants