summaryrefslogtreecommitdiff
path: root/src/js.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-03-19 12:10:42 +0100
committerportix <portix@gmx.net>2012-03-19 12:10:42 +0100
commit24dd173e5822267a4311cf34be8a88e0ad5b1f93 (patch)
tree735775b699ac41b351dbc6abe0f67d243c9164fc /src/js.c
parent25b1ae816280408d409b7bcd098c34cd40de7792 (diff)
downloaddwb-24dd173e5822267a4311cf34be8a88e0ad5b1f93.zip
Fixing possible memory leak in js_create_object
Diffstat (limited to 'src/js.c')
-rw-r--r--src/js.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/js.c b/src/js.c
index 84e72348..cddae891 100644
--- a/src/js.c
+++ b/src/js.c
@@ -88,20 +88,23 @@ js_create_object(WebKitWebFrame *frame, const char *script) {
if (script == NULL)
return NULL;
- JSStringRef prop_name;
- JSValueRef prop, exc = NULL;
+ JSStringRef prop_name, js_script;
+ JSValueRef prop, ret, exc = NULL;
+ JSObjectRef return_object;
+ JSPropertyNameArrayRef array;
JSContextRef ctx = webkit_web_frame_get_global_context(frame);
- JSStringRef jsscript = JSStringCreateWithUTF8CString(script);
- JSValueRef ret = JSEvaluateScript(ctx, jsscript, NULL, NULL, 0, &exc);
+ js_script = JSStringCreateWithUTF8CString(script);
+ ret = JSEvaluateScript(ctx, js_script, NULL, NULL, 0, &exc);
+ JSStringRelease(js_script);
if (exc != NULL)
return NULL;
- JSStringRelease(jsscript);
- JSObjectRef return_object = JSValueToObject(ctx, ret, &exc);
+
+ return_object = JSValueToObject(ctx, ret, &exc);
if (exc != NULL)
return NULL;
JSValueProtect(ctx, ret);
- JSPropertyNameArrayRef array = JSObjectCopyPropertyNames(ctx, return_object);
+ array = JSObjectCopyPropertyNames(ctx, return_object);
for (int i=0; i<JSPropertyNameArrayGetCount(array); i++) {
prop_name = JSPropertyNameArrayGetNameAtIndex(array, i);
prop = JSObjectGetProperty(ctx, return_object, prop_name, NULL);