Backed out changeset 1052ee218ba6
authorDão Gottwald <dao@mozilla.com>
Sun, 02 May 2010 14:19:54 +0200
changeset 41716 db0ab327af16f92c8987cd23be63f32dd4098019
parent 41714 1052ee218ba660b56c591af93a6e7bf7de644260
child 41717 7b31407a4814537a9648e4c2c4c660e257bc3066
push idunknown
push userunknown
push dateunknown
milestone1.9.3a5pre
backs out1052ee218ba660b56c591af93a6e7bf7de644260
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Backed out changeset 1052ee218ba6
modules/plugin/base/public/npruntime.h
modules/plugin/test/testplugin/nptest.cpp
--- a/modules/plugin/base/public/npruntime.h
+++ b/modules/plugin/base/public/npruntime.h
@@ -194,18 +194,17 @@ NP_END_MACRO
 NP_BEGIN_MACRO                                                                \
     (_v).type = NPVariantType_Double;                                         \
     (_v).value.doubleValue = _val;                                            \
 NP_END_MACRO
 
 #define STRINGZ_TO_NPVARIANT(_val, _v)                                        \
 NP_BEGIN_MACRO                                                                \
     (_v).type = NPVariantType_String;                                         \
-    NPString str = { _val, 0 };                                               \
-    str.UTF8Length = uint32_t(strlen(str.UTF8Characters));                    \
+    NPString str = { _val, uint32_t(strlen(_val)) };                          \
     (_v).value.stringValue = str;                                             \
 NP_END_MACRO
 
 #define STRINGN_TO_NPVARIANT(_val, _len, _v)                                  \
 NP_BEGIN_MACRO                                                                \
     (_v).type = NPVariantType_String;                                         \
     NPString str = { _val, uint32_t(_len) };                                  \
     (_v).value.stringValue = str;                                             \
--- a/modules/plugin/test/testplugin/nptest.cpp
+++ b/modules/plugin/test/testplugin/nptest.cpp
@@ -1617,22 +1617,17 @@ scriptableInvokeDefault(NPObject* npobj,
         break;
       case NPVariantType_Null:
         value << ";null";
         break;
       default:
         value << ";other";
     }
   }
-  char *pstr = strdup(value.str().c_str());
-  if (!pstr) {
-    NPN_SetException(npobj, "oom");
-    return false;
-  }
-  STRINGZ_TO_NPVARIANT(pstr, *result);
+  STRINGZ_TO_NPVARIANT(strdup(value.str().c_str()), *result);
   return true;
 }
 
 bool
 scriptableHasProperty(NPObject* npobj, NPIdentifier name)
 {
   for (int i = 0; i < int(ARRAY_LENGTH(sPluginPropertyIdentifiers)); i++) {
     if (name == sPluginPropertyIdentifiers[i])
@@ -2106,23 +2101,20 @@ getWidthAtLastPaint(NPObject* npobj, con
 static bool
 getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   if (argCount != 0)
     return false;
 
   NPP npp = static_cast<TestNPObject*>(npobj)->npp;
   InstanceData* id = static_cast<InstanceData*>(npp->pdata);
-  const char *cstr = id->err.str().length() ? id->err.str().c_str() : SUCCESS_STRING;
-  char *pstr = strdup(cstr);
-  if (!pstr) {
-    NULL_TO_NPVARIANT(*result);
-    return true;
-  }
-  STRINGZ_TO_NPVARIANT(pstr, *result);
+  if (id->err.str().length() == 0)
+    STRINGZ_TO_NPVARIANT(strdup(SUCCESS_STRING), *result);
+  else
+    STRINGZ_TO_NPVARIANT(strdup(id->err.str().c_str()), *result);
   return true;
 }
 
 static bool
 doInternalConsistencyCheck(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
 {
   if (argCount != 0)
     return false;