0

chrome newer version(14) does not give a null terminated string as part of NPVariant whereas firefox acts differently and gives a null terminated string. Is that expected ??

What can we do other than extracting a string,allocating memory and add null character and then deallocating the same..... all this just to add a null character??

mohit
  • 105
  • 1
  • 8

1 Answers1

2

NPVariant NPStrings have never been required to include a NULL terminated string. Sometimes they did anyway. What they do include, however, is a "length" to indicate how long the string is; I generally just convert it to a std::string like so:

retVal = std::string(npVar->value.stringValue.UTF8Characters, npVar->value.stringValue.UTF8Length);

That is how FireBreath does it; https://github.com/firebreath/FireBreath/blob/master/src/NpapiCore/NpapiBrowserHost.cpp#L253

taxilian
  • 14,229
  • 4
  • 34
  • 73