Closed Bug 730140 Opened 12 years ago Closed 12 years ago

NUL-terminate strings when dumping the heap

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: sfink, Assigned: sfink)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

There were a couple of paths through the heap-dumping where the buffer was not NUL-terminated (when no detail was available, or when detail was available but one of the cases was chosen that didn't generate anything). With this patch, I don't seem to see any more mangled strings in the heap dump output.
Attachment #600216 - Flags: review?(continuation)
Comment on attachment 600216 [details] [diff] [review]
NUL-terminate strings when dumping the heap

Review of attachment 600216 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for looking into this!

This part of OBJECT needs a null terminator in the else branch:

2545                     if (fun->atom)
2546                         PutEscapedString(buf, bufsize, fun->atom, 0);

I'm not sure what the best way to do that is.  r=me with that.
Attachment #600216 - Flags: review?(continuation) → review+
Oh, and while you are there, if you could remove the totally useless:

-#ifdef HAVE_XPCONNECT
-#include "dump_xpc.h"
-#endif

that would be great.  Thanks.
and this glob:
-#ifdef HAVE_XPCONNECT
-        if (clasp->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS) {
-            void *privateThing = obj->getPrivate();
-            if (privateThing) {
-                const char *xpcClassName = GetXPCObjectClassName(privateThing);
-                if (xpcClassName)
-                    name = xpcClassName;
-            }
-        }
-#endif
(In reply to Andrew McCreight [:mccr8] from comment #2)
> This part of OBJECT needs a null terminator in the else branch:
> 
> 2545                     if (fun->atom)
> 2546                         PutEscapedString(buf, bufsize, fun->atom, 0);
> 
> I'm not sure what the best way to do that is.  r=me with that.

Doh! Didn't notice that one lurking there. It also shouldn't have a space prepended, so I moved the space into the printfs.

https://hg.mozilla.org/integration/mozilla-inbound/rev/52fe920f2685
Target Milestone: --- → mozilla15
Target Milestone: mozilla15 → mozilla13
https://hg.mozilla.org/mozilla-central/rev/52fe920f2685
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Blocks: 723783
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: