NPVARIANT_TO_STRING doesn't guarantee to have a null-terminated string, the provided length should be taken in account to assign the value to other objects. Some browsers (e.g.: chromium) pass numeric properties as double instead of int32, in order to use the specified values the support for double has been added. Signed-off-by: Federico Simoncelli <fsimonce@xxxxxxxxxx> --- SpiceXPI/src/plugin/nsScriptablePeer.cpp | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/SpiceXPI/src/plugin/nsScriptablePeer.cpp b/SpiceXPI/src/plugin/nsScriptablePeer.cpp index caab9b7..622659c 100644 --- a/SpiceXPI/src/plugin/nsScriptablePeer.cpp +++ b/SpiceXPI/src/plugin/nsScriptablePeer.cpp @@ -242,12 +242,14 @@ bool ScriptablePluginObject::SetProperty(NPIdentifier name, const NPVariant *val return false; std::string str; + std::stringstream ss; PRBool boolean = false; unsigned short val = -1; if (NPVARIANT_IS_STRING(*value)) { - str = NPVARIANT_TO_STRING(*value).UTF8Characters; + str.assign(NPVARIANT_TO_STRING(*value).UTF8Characters, + NPVARIANT_TO_STRING(*value).UTF8Length); } else if (NPVARIANT_IS_BOOLEAN(*value)) { @@ -256,8 +258,12 @@ bool ScriptablePluginObject::SetProperty(NPIdentifier name, const NPVariant *val else if (NPVARIANT_IS_INT32(*value)) { val = NPVARIANT_TO_INT32(*value); - - std::stringstream ss; + ss << val; + ss >> str; + } + else if (NPVARIANT_IS_DOUBLE(*value)) + { + val = NPVARIANT_TO_DOUBLE(*value); ss << val; ss >> str; } -- 1.7.1 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/spice-devel