Fix memleaks and double-free issues with xpath
diff --git a/axiom/src/xpath/xpath.c b/axiom/src/xpath/xpath.c
index 90f44ad..866d4f5 100755
--- a/axiom/src/xpath/xpath.c
+++ b/axiom/src/xpath/xpath.c
@@ -66,9 +66,7 @@
 
     if (axiom_xpath_compile(env, expr) == AXIOM_XPATH_PARSE_ERROR)
     {
-        AXIS2_FREE(env->allocator, expr->expr_str);
-        AXIS2_FREE(env->allocator, expr);
-
+        axiom_xpath_free_expression(env, expr);
         return NULL;
     }
     else
@@ -371,7 +369,7 @@
         /* Free the expression if not freed */
         if (context->expr)
         {
-            /* axiom_xpath_free_expression(env, context->expr); */
+            axiom_xpath_free_expression(env, context->expr);
 
             context->expr = NULL;
         }
@@ -416,6 +414,15 @@
 
         if (xpath_expr->operations)
         {
+            axiom_xpath_operation_t *op = NULL;
+            while(axutil_array_list_size(xpath_expr->operations, env)) {
+                op = axutil_array_list_remove(xpath_expr->operations, env, 0);
+                if (op->par1)
+                    AXIS2_FREE(env->allocator, op->par1);
+                if (op->par2)
+                    AXIS2_FREE(env->allocator, op->par2);
+                AXIS2_FREE(env->allocator, op);
+            }
             axutil_array_list_free(xpath_expr->operations, env);
             xpath_expr->operations = NULL;
         }
@@ -434,6 +441,11 @@
     {
         if (result->nodes)
         {
+            axiom_xpath_result_node_t *node = NULL;
+            while(axutil_array_list_size(result->nodes, env)) {
+                node = axutil_array_list_remove(result->nodes, env, 0);
+                AXIS2_FREE(env->allocator, node);
+            }
             axutil_array_list_free(result->nodes, env);
         }
 
diff --git a/axiom/src/xpath/xpath_internals_engine.c b/axiom/src/xpath/xpath_internals_engine.c
index 3c96d0e..41ca3f1 100644
--- a/axiom/src/xpath/xpath_internals_engine.c
+++ b/axiom/src/xpath/xpath_internals_engine.c
@@ -52,6 +52,7 @@
     }
 
     axutil_stack_free(context->stack, context->env);
+    context->stack = NULL;
 
     return res;
 }
diff --git a/axiom/src/xpath/xpath_internals_parser.c b/axiom/src/xpath/xpath_internals_parser.c
index a1ce79a..e753680 100755
--- a/axiom/src/xpath/xpath_internals_parser.c
+++ b/axiom/src/xpath/xpath_internals_parser.c
@@ -45,8 +45,6 @@
 
     if(expr->start == AXIOM_XPATH_PARSE_ERROR)
     {
-        axutil_array_list_free(expr->operations, env);
-
         return AXIOM_XPATH_PARSE_ERROR;
     }
     else
@@ -717,6 +715,7 @@
             expr->expr_str + expr->expr_ptr);
 #endif
 
+        AXIS2_FREE(env->allocator, node_test);
         return AXIOM_XPATH_PARSE_ERROR;
     }
 
@@ -1202,7 +1201,7 @@
 
     name[i] = '\0';
 
-    return axutil_strdup(env, name);
+    return name;
 }
 
 /* Supporting functions */
diff --git a/axiom/test/xpath/test_xpath.cc b/axiom/test/xpath/test_xpath.cc
index b4af702..44a5df3 100644
--- a/axiom/test/xpath/test_xpath.cc
+++ b/axiom/test/xpath/test_xpath.cc
@@ -274,11 +274,6 @@
     {
         axiom_xpath_free_result(env, result);
     }
-
-    if (expr)
-    {
-        axiom_xpath_free_expression(env, expr);
-    }
 }
 
 int compare_result(axis2_char_t *rs)