p = parse_name (p, end, &name);
if (p == end)
return p;
+
p = skip_space (p, end);
- if (p == end)
+ if (p == end){
+ free (name);
return p;
+ }
if (*p != '='){
set_error ("Expected an = after the attribute name `%s'", name);
+ free (name);
return end;
}
p++;
p = skip_space (p, end);
- if (p == end)
+ if (p == end){
+ free (name);
return end;
+ }
p = parse_value (p, end, &value, error);
- if (p == end)
+ if (p == end){
+ free (name);
return p;
+ }
++nnames;
*names = g_realloc (*names, sizeof (char **) * (nnames+1));
g_strfreev (names);
g_strfreev (values);
}
-
- set_error ("Unfinished sequence");
+ /* Only set the error if parse_attributes did not */
+ if (error != NULL && *error == NULL)
+ set_error ("Unfinished sequence");
goto fail;
}
l = element_end - element_start;
g_strfreev (values);
}
- if (error != NULL && *error != NULL)
+ if (error != NULL && *error != NULL){
+ free (ename);
goto fail;
+ }
if (full_stop){
if (context->parser.end_element != NULL){
context->parser.end_element (context, ename, context->user_data, error);
- if (error != NULL && *error != NULL)
+ if (error != NULL && *error != NULL){
+ free (ename);
goto fail;
+ }
}
+ free (ename);
} else
context->level = g_slist_prepend (context->level, ename);
case CLOSING_ELEMENT: {
GSList *current = context->level;
+ char *text;
if (context->level == NULL){
set_error ("Too many closing tags, not enough open tags");
goto fail;
}
+ text = current->data;
if (context->parser.end_element != NULL){
- char *text = current->data;
-
context->parser.end_element (context, text, context->user_data, error);
- if (error != NULL && *error != NULL)
+ if (error != NULL && *error != NULL){
+ free (text);
goto fail;
+ }
}
+ free (text);
+
context->level = context->level->next;
g_slist_free_1 (current);
break;
#include <glib.h>
#include "test.h"
-#define do_bad_test(s) do { char *r = markup_test (s); if (r == NULL) return FAILED ("Failed on test " # s); } while (0)
+#define do_bad_test(s) do { char *r = markup_test (s); if (r == NULL) return FAILED ("Failed on test " # s); else free (r); } while (0)
#define do_ok_test(s) do { char *r = markup_test (s); if (r != NULL) return FAILED ("Could not parse valid " # s); } while (0)
static char *
char *msg = g_strdup (error->message);
g_error_free (error);
+ g_free (parser);
return msg;
}
+ g_free (parser);
return NULL;
}
{
AppConfigInfo *info;
- info = domain_test ("<configuration><!--hello--><startup><!--world--><requiredRuntime version=\"v1\"><!--r--></requiredRuntime></startup></configuration>");
+ info = domain_test ("<configuration><!--hello--><startup><!--world--><requiredRuntime version=\"v1\"><!--r--></requiredRuntime></startup></configuration>");
if (info->required_runtime == NULL)
return FAILED ("No required runtime section");
if (strcmp (info->required_runtime, "v1") != 0)