Closed Bug 564068 Opened 12 years ago Closed 12 years ago

Test plugin should use NPN allocator to create strings

Categories

(Core Graveyard :: Plug-ins, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: neil, Unassigned)

Details

Attachments

(1 file)

STRINGZ_TO_NPVARIANT assumes a string allocated with memalloc, not strdup. The test plugin can cheat because it links with MOZCRT19, but real plugins won't.

There's no NPN strdup function, but one could be created like this:

char*
NPN_StrDup(const char* str)
{
  return strcpy((char*)sBrowserFuncs->memalloc(strlen(str) + 1), str);
}
Also the test plugin needs to be compiled with USE_STATIC_LIBS=1 to stop this mistake happening in future.
Attached patch Possible patchSplinter Review
If I only set USE_STATIC_LIBS = 1 then my debug non-jemalloc build aborts the test because it tries to free memory allocated on the wrong heap, and the rest of the patch fixes that. I'm not actually sure that any tinderboxes would test for that, since I can't build with jemalloc.
Attachment #444203 - Flags: review?(jst)
Attachment #444203 - Flags: review?(jst) → review+
Pushed changeset aa0171d36805 to mozilla-central.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.