[anjuta] language-support-js: Fixed bgo#665082 - Crash in javascript autocompletion
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] language-support-js: Fixed bgo#665082 - Crash in javascript autocompletion
- Date: Wed, 30 Nov 2011 18:54:20 +0000 (UTC)
commit 4b41d02658a6dc07dc1216a74e424984a0563ee7
Author: Johannes Schmid <jhs gnome org>
Date: Wed Nov 30 19:53:35 2011 +0100
language-support-js: Fixed bgo#665082 - Crash in javascript autocompletion
This bug was caused by a memory error in the javascript plugin that is now fixed. Also fixed some memory leaks.
plugins/language-support-js/database-symbol.c | 1 -
plugins/language-support-js/local-symbol.c | 2 +-
plugins/language-support-js/node-symbol.c | 2 +-
.../symbol-db/anjuta-tags/js-parser/js-context.c | 30 ++++++++-----------
plugins/symbol-db/anjuta-tags/js-parser/js-node.c | 5 ++-
plugins/symbol-db/anjuta-tags/js-parser/js-node.h | 2 +-
plugins/symbol-db/anjuta-tags/js-parser/jsparse.c | 1 -
7 files changed, 19 insertions(+), 24 deletions(-)
---
diff --git a/plugins/language-support-js/database-symbol.c b/plugins/language-support-js/database-symbol.c
index b74832d..92cd26a 100644
--- a/plugins/language-support-js/database-symbol.c
+++ b/plugins/language-support-js/database-symbol.c
@@ -96,7 +96,6 @@ database_symbol_set_file (DatabaseSymbol *object, const gchar* filename)
priv->local = local_symbol_new (filename);
missed = local_symbol_get_missed_semicolons (priv->local);
highlight_lines (missed);
- g_list_free (missed);
}
DatabaseSymbol*
diff --git a/plugins/language-support-js/local-symbol.c b/plugins/language-support-js/local-symbol.c
index 969ff9e..21adc3b 100644
--- a/plugins/language-support-js/local-symbol.c
+++ b/plugins/language-support-js/local-symbol.c
@@ -99,7 +99,7 @@ local_symbol_new (const gchar *filename)
priv->node = js_node_new_from_file (filename);
if (priv->node)
{
- priv->missed_semicolon = g_list_copy (js_node_get_lines_missed_semicolon (priv->node));
+ priv->missed_semicolon = js_node_get_lines_missed_semicolon (priv->node);
priv->calls = NULL;
priv->my_cx = js_context_new_from_node (priv->node, &priv->calls);
diff --git a/plugins/language-support-js/node-symbol.c b/plugins/language-support-js/node-symbol.c
index 8a5510f..c5b7601 100644
--- a/plugins/language-support-js/node-symbol.c
+++ b/plugins/language-support-js/node-symbol.c
@@ -131,7 +131,7 @@ node_symbol_get_arg_list (IJsSymbol *obj)
for (i = args->pn_u.list.head; i; i = i->pn_next)
{
- ret = g_list_append (ret, g_strdup (js_node_get_name (i)));
+ ret = g_list_append (ret, js_node_get_name (i));
}
}
diff --git a/plugins/symbol-db/anjuta-tags/js-parser/js-context.c b/plugins/symbol-db/anjuta-tags/js-parser/js-context.c
index 007e79e..9bf2278 100644
--- a/plugins/symbol-db/anjuta-tags/js-parser/js-context.c
+++ b/plugins/symbol-db/anjuta-tags/js-parser/js-context.c
@@ -131,7 +131,7 @@ Type*
js_context_get_node_type (JSContext *my_cx, JSNode *node)
{
Type *ret;
- const gchar *name;
+ gchar *name;
if (!node)
return NULL;
@@ -155,10 +155,10 @@ js_context_get_node_type (JSContext *my_cx, JSNode *node)
if (tname)
return tname;
else
- ret->name = g_strdup (name);
+ ret->name = name;
}
else
- ret->name = g_strdup (name);
+ ret->name = name;
return ret;
}
break;
@@ -175,10 +175,10 @@ js_context_get_node_type (JSContext *my_cx, JSNode *node)
if (tname)
return tname;
else
- ret->name = g_strdup (name);
+ ret->name = name;
}
else
- ret->name = g_strdup (name);
+ ret->name = name;
return ret;
}
break;
@@ -237,8 +237,7 @@ js_context_get_node_type (JSContext *my_cx, JSNode *node)
g_assert_not_reached ();
else
{
-// puts (name);
- ret->name = g_strdup (name);
+ ret->name = name;
return ret;
}
break;
@@ -248,9 +247,8 @@ js_context_get_node_type (JSContext *my_cx, JSNode *node)
g_assert_not_reached ();
else
{
-// printf ("call %s\n",name);
ret->isFuncCall = TRUE;
- ret->name = g_strdup (name);
+ ret->name = name;
return ret;
}
break;
@@ -341,7 +339,7 @@ interpretator (JSNode *node, JSContext *my_cx, GList **calls)
tvar->node = node;
if (node->pn_u.func.name) {
- tvar->name = g_strdup (js_node_get_name (node->pn_u.func.name));
+ tvar->name = js_node_get_name (node->pn_u.func.name);
//puts (tvar->name);
}
if (tvar->name)
@@ -383,7 +381,7 @@ interpretator (JSNode *node, JSContext *my_cx, GList **calls)
for (i = JS_NODE (i->pn_u.list.head); i; i = JS_NODE (i->pn_next))
{
g_assert (i->pn_arity == PN_NAME);
- t->func_arg = g_list_append (t->func_arg, g_strdup (js_node_get_name (i)));
+ t->func_arg = g_list_append (t->func_arg, js_node_get_name (i));
}
}
}
@@ -406,11 +404,11 @@ interpretator (JSNode *node, JSContext *my_cx, GList **calls)
break;
case TOK_LP:
{
- const gchar *fname = js_node_get_name (node->pn_u.list.head);
+ gchar *fname = js_node_get_name (node->pn_u.list.head);
if (!fname)
break;
FuncCall *t = g_new (FuncCall, 1);
- t->name = g_strdup (fname);
+ t->name = fname;
t->list = ((JSNode*)node->pn_u.list.head)->pn_next;
*calls = g_list_append (*calls, t);
//printf ("call to %s\n", t->name);
@@ -421,9 +419,8 @@ interpretator (JSNode *node, JSContext *my_cx, GList **calls)
{
g_assert (iter->pn_type == TOK_NAME);
- const gchar *name = js_node_get_name (iter);
Var *t = g_new (Var, 1);
- t->name = g_strdup (name);
+ t->name = js_node_get_name (iter);
t->node = iter->pn_u.name.expr;
t->line = iter->pn_pos.end;
my_cx->local_var = g_list_append (my_cx->local_var, t);
@@ -446,9 +443,8 @@ interpretator (JSNode *node, JSContext *my_cx, GList **calls)
{
if (!node->pn_u.binary.left)
break;
- const gchar *name = js_node_get_name (node->pn_u.binary.left);
Var *t = (Var *)g_new (Var, 1);
- t->name = g_strdup (name);
+ t->name = js_node_get_name (node->pn_u.binary.left);
t->node = node->pn_u.binary.right;
t->line = node->pn_pos.end;
my_cx->local_var = g_list_append (my_cx->local_var, t);
diff --git a/plugins/symbol-db/anjuta-tags/js-parser/js-node.c b/plugins/symbol-db/anjuta-tags/js-parser/js-node.c
index 569258d..982b6b7 100644
--- a/plugins/symbol-db/anjuta-tags/js-parser/js-node.c
+++ b/plugins/symbol-db/anjuta-tags/js-parser/js-node.c
@@ -97,11 +97,12 @@ js_node_class_init (JSNodeClass *klass)
object_class->finalize = js_node_finalize;
}
-const gchar*
+gchar*
js_node_get_name (JSNode *node)
{
g_return_val_if_fail (node, NULL);
g_assert (JS_IS_NODE (node));
+
if (node->pn_arity == PN_NULLARY)
{
return NULL;
@@ -111,7 +112,7 @@ js_node_get_name (JSNode *node)
switch ((JSTokenType)node->pn_type)
{
case TOK_NAME:
- return node->pn_u.name.name;
+ return g_strdup(node->pn_u.name.name);
break;
case TOK_DOT:
if (!node->pn_u.name.expr || !node->pn_u.name.name)
diff --git a/plugins/symbol-db/anjuta-tags/js-parser/js-node.h b/plugins/symbol-db/anjuta-tags/js-parser/js-node.h
index 1ad3e5d..228b0a7 100644
--- a/plugins/symbol-db/anjuta-tags/js-parser/js-node.h
+++ b/plugins/symbol-db/anjuta-tags/js-parser/js-node.h
@@ -81,7 +81,7 @@ struct _JSNode
};
GType js_node_get_type (void) G_GNUC_CONST;
-const gchar* js_node_get_name (JSNode *node);
+gchar* js_node_get_name (JSNode *node);
JSNode* js_node_new_from_file (const gchar *name);
GList* js_node_get_list_member_from_rc (JSNode* node);
JSNode* js_node_get_member_from_rc (JSNode* node, const gchar *mname);
diff --git a/plugins/symbol-db/anjuta-tags/js-parser/jsparse.c b/plugins/symbol-db/anjuta-tags/js-parser/jsparse.c
index 69c522d..c906599 100644
--- a/plugins/symbol-db/anjuta-tags/js-parser/jsparse.c
+++ b/plugins/symbol-db/anjuta-tags/js-parser/jsparse.c
@@ -36,7 +36,6 @@ print_node (JSNode *node, char *pref)
{
g_assert (iter->pn_type == TOK_NAME);
-/* const gchar *name = js_node_get_name(iter);*/
break;
}
case TOK_LP:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]