Opened 4 years ago
Closed 4 years ago
#1021 closed defect (fixed)
non-POD types passed to .../va_start is UB
Reported by: | gdt | Owned by: | strk |
---|---|---|---|
Priority: | minor | Milestone: | 3.8.2 |
Component: | C API | Version: | 3.8.0 |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
In capi/geos_ts_c.cpp, the NOTICE and ERROR functions are variadic and take a std::string as the first argument. They then call va_start with this non-POD type. This lands us in "conditionally defined" behavior (5.2.2 clause 7), which given multiple possible compilers is really "undefined behavior". Some links which help explain why this is a painful situation.
I have attached a patch which avoids the issue, essentially by hoisting the c_str() before the call (and making it implicit). With this patch and 3.8.1, tests pass on NetBSD 8 amd64 and macOS 10.13 amd64.
Attachments (1)
Change History (6)
by , 4 years ago
Attachment: | patch-capi_geos__ts__c.cpp added |
---|
comment:1 by , 4 years ago
Milestone: | 3.9.0 → 3.8.1 |
---|
comment:2 by , 4 years ago
Milestone: | 3.8.1 → 3.8.2 |
---|
comment:4 by , 4 years ago
Huh, I actually have a unit test failure on OSX, with this patch still.
Darwin Kernel Version 19.4.0 MacOS 10.15
CI seems has come up green though...
This might as well be fixed in 3.8.2 as well as master; picking 3.8.1 as meaning 3.8.2.