OSGeo / grass-addons

GRASS GIS Addons Repository
https://grass.osgeo.org/grass-stable/manuals/addons/
GNU General Public License v2.0
99 stars 150 forks source link

[Bug] v.percolate without option "id=" makes it crash (segfault) #471

Open neteler opened 3 years ago

neteler commented 3 years ago

Hi. I found that running v.percolate without option "id=" makes it crash (segfault). Weirdly, I should not even be able to run it without that option: The module interface description says that "id=" is required.

But it seems to have a default value that points to unallocated memory.

This is what valgrind says: Invalid read of size 8 at 0x4B1E383: db_close_database (in /opt/grass/lib/libgrass_dbmiclient.7.8.so) by 0x4B2103E: db_close_database_shutdown_driver (in /opt/grass/lib/libgrass_dbmiclient.7.8.so) by 0x40526D: read_input_vector (vector.c:149) by 0x402749: main (main.c:268) Address 0x310 is not stack'd, malloc'd or (recently) free'd

Originally posted by @benducke in https://github.com/OSGeo/grass-addons/issues/382#issuecomment-791526427

neteler commented 3 years ago

Can you please check, @mwlake ? Thanks

HuidaeCho commented 3 years ago

By default, a G_OPT_V_FIELD option gets assigned 1, but @mwlake might have wanted to explicitly require it by clearing it out, but input_id->answer = NULL; should be the right way, not an empty string.

mwlake commented 3 years ago

Thanks @benducke. I can replicate this and will look to fix it this week.