51 lines
1.7 KiB
Diff
51 lines
1.7 KiB
Diff
commit 08ed898f10ee888497708299f28d91fc67602699
|
|
Author: Colin Walters <walters@verbum.org>
|
|
Date: Wed Dec 15 18:52:13 2010 -0500
|
|
|
|
More fixes for previous commit
|
|
|
|
* Change to always malloc() to avoid compiler warnings
|
|
* Add missing brackets to fix control flow
|
|
|
|
diff --git a/gjs/stack.c b/gjs/stack.c
|
|
index 92b589d..90d15b6 100644
|
|
--- a/gjs/stack.c
|
|
+++ b/gjs/stack.c
|
|
@@ -83,7 +83,6 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
|
JSPropertyDescArray call_props = { 0, NULL };
|
|
JSObject* this_obj = NULL;
|
|
JSObject* call_obj = NULL;
|
|
- JSString* funname = NULL;
|
|
char* funname_str = NULL;
|
|
const char* filename = NULL;
|
|
guint32 lineno = 0;
|
|
@@ -115,14 +114,15 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
|
filename = JS_GetScriptFilename(cx, script);
|
|
lineno = (guint32) JS_PCToLineNumber(cx, script, pc);
|
|
fun = JS_GetFrameFunction(cx, fp);
|
|
- if (fun)
|
|
+ if (fun) {
|
|
#ifdef HAVE_JS_GETFUNCTIONNAME
|
|
- funname_str = JS_GetFunctionName(fun);
|
|
+ funname_str = g_strdup(JS_GetFunctionName(fun));
|
|
#else
|
|
- funname = JS_GetFunctionId(fun);
|
|
+ JSString* funname = JS_GetFunctionId(fun);
|
|
if (funname)
|
|
funname_str = gjs_string_get_ascii(cx, STRING_TO_JSVAL(funname));
|
|
#endif
|
|
+ }
|
|
|
|
call_obj = JS_GetFrameCallObject(cx, fp);
|
|
if (call_obj) {
|
|
@@ -149,9 +149,7 @@ format_frame(JSContext* cx, JSStackFrame* fp,
|
|
|
|
if (funname_str) {
|
|
g_string_append_printf(buf, "%d %s(", num, funname_str);
|
|
-#ifndef HAVE_JS_GETFUNCTIONNAME
|
|
g_free(funname_str);
|
|
-#endif
|
|
}
|
|
else if (fun)
|
|
g_string_append_printf(buf, "%d anonymous(", num);
|