Conversation
TheMarex
left a comment
There was a problem hiding this comment.
Sensible hardening. Looks good to me.
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in osrm-extract when processing OpenStreetMap data with invalid lane tags (non-integer or negative values), specifically addressing crashes when processing Switzerland data.
Key changes:
- Added
to_number_uintfunction to validate lane count values as positive integers - Replaced all
tonumbercalls for lane-related tag parsing with the new validation function
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'emergency_access' | ||
| } | ||
|
|
||
| local function to_number_uint(s) |
There was a problem hiding this comment.
The function name to_number_uint suggests it returns an unsigned integer, but the implementation rejects 0 with the condition n > 0. In most programming contexts, unsigned integers include 0 (e.g., range is 0 to 2^32-1). While rejecting 0 is correct for lane counts (a road cannot have 0 lanes), consider naming it to_positive_int or to_number_positive_int for clarity.
Fixed bug with non-integer (or negative) lane tags.
Right now, osrm-extract crashes on Switzerland.