Closed Bug 569871 Opened 16 years ago Closed 16 years ago

Heap corruption when executes script with specific code

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: dex_1988, Unassigned)

Details

User-Agent: Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.5.24 Version/10.53 Build Identifier: 1.8.0 pre (Source getting from firefox 3.6.3) I'm embedding TraceMonkey in my application, and declare object "navigator"(no global) with read-only property "userAgent", that contains string value. This value maked by function JS_NewString and parameter 'const char* s' take the pointer to the global char pointer(static char* mystr = "bla";). And then evaluates script that use property "userAgent" program crashes with heap corruption. Reproducible: Always Steps to Reproduce: 1. Embed engine(TraceMonkey) 2. Make object with read only string property, that initialize by function JS_NewString from global char pointer 3. Evaluate script, that use this property Actual Results: The program crashed with heap corruption error Expected Results: Correct a bug Crash in jsgc.cpp; buildconfig: compiler - msvc 9 sp1, OS - win xp sp3, library builds as static lib
> This value maked by function JS_NewString What does the code for this look like?
JS_NewString takes ownership of the malloc'ed char *buffer you pass into it. It will free it eventually. Please see the API docs, and use JS_NewStringCopyZ (in this case). Making new strings containing the same chars over and over is a bit inefficient too, but you can fix that by using JS_InternString. /be
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
OK. Sorry for fake report.
You need to log in before you can comment on or make changes to this bug.