protomaps / OSMExpress

Fast database file format for OpenStreetMap
BSD 2-Clause "Simplified" License
229 stars 19 forks source link

Segfault running query command with no arguments #16

Closed CloudNiner closed 4 years ago

CloudNiner commented 4 years ago

If I run

> osmx query path/to/db.osmx
Segmentation fault

I get a segfault attempting to read argv[3]: https://github.com/protomaps/OSMExpress/blob/master/src/cmd.cpp#L48

The docs indicate that calling the query in this form should be possible: https://github.com/protomaps/OSMExpress#command-line

As a temporary workaround, providing some random third arg so that the code falls back into the else case works:

> osmx query path/to/db.osmx print
locations: 20377226
nodes: 418210
ways: 2168392
relations: 31391
cell_node: 20377226
node_way: 22504715
node_relation: 27683
way_relation: 393230
relation_relation: 1459
Timestamp: 2020-04-02T20:59:01Z
Sequence #: 2572
bdon commented 4 years ago

@CloudNiner should be fixed, can you confirm by pulling master? also cleaned up some of the help output logic

CloudNiner commented 4 years ago

Works great, nice fix there adding the fallback to print the help if an invalid query command is provided 🎉