FreeOpcUa / freeopcua

Open Source C++ OPC-UA Server and Client Library
http://freeopcua.github.io/
GNU Lesser General Public License v3.0
712 stars 342 forks source link

Bug: Writing empty string to the OPC UA server results in Null object with length -1 #127

Open destogl opened 9 years ago

destogl commented 9 years ago

Hello,

last week during some test we found out that empty string (length 0) is written as Null object with length -1 into the server. The server on itself didn't have any problems with that some other clients like pyUAF was crashing when try to read variable. Currently I found workaround but it would be good to handle this on serializer level.

The workaround:

''' if (variant.Type() == OpcUa::VariantType::STRING) { if (((std::string)variant).length() == 0) { variant = std::string(" "); } } '''

oroulet commented 9 years ago

Yes we need to fix the variant... On Mar 30, 2015 11:05 AM, "Denis Štogl" notifications@github.com wrote:

Hello,

last week during some test we found out that empty string (length 0) is written as Null object with length -1 into the server. The server on itself didn't have any problems with that some other clients like pyUAF https://uaf.github.io/uaf/doc/pyuaf/ was crashing when try to read variable. Currently I found workaround but it would be good to handle this on serializer level.

The workaround:

''' if (variant.Type() == OpcUa::VariantType::STRING) { if (((std::string)variant).length() == 0) { variant = std::string(" "); } } '''

— Reply to this email directly or view it on GitHub https://github.com/FreeOpcUa/freeopcua/issues/127.