-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
SerialPort Version
10
Node Version
No response
Electron Version
No response
Platform
No response
Architecture
No response
Hardware or chipset of serialport
No response
What steps will reproduce the bug?
Parity options do not work on windows, because the temporary string in ToParityEnum gets destroyed before the comparison, leading to an invalid pointer in str.
Fix:
diff --git a/node_modules/@serialport/bindings/src/serialport.cpp b/node_modules/@serialport/bindings/src/serialport.cpp
index c48e150..00a5f5a 100644
--- a/node_modules/@serialport/bindings/src/serialport.cpp
+++ b/node_modules/@serialport/bindings/src/serialport.cpp
@@ -269,7 +269,8 @@ Napi::Value Drain(const Napi::CallbackInfo& info) {
}
inline SerialPortParity ToParityEnum(const Napi::String& napistr) {
- const char* str = napistr.Utf8Value().c_str();
+ auto tmp = napistr.Utf8Value();
+ const char* str = tmp.c_str();
size_t count = strlen(str);
SerialPortParity parity = SERIALPORT_PARITY_NONE;
if (!strncasecmp(str, "none", count)) {
What happens?
What should have happened?
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels