Skip to content

Commit 0de600a

Browse files
author
Danny Milosavljevic
committed
svd_viewer: Fix some memory leaks.
1 parent 8293a00 commit 0de600a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

svd_viewer.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static void resolve_derivedFrom(xmlNodePtr root) {
123123
} else {
124124
g_warning("Could not find register referenced: '%s'", derivedFrom);
125125
}
126+
xmlFree(derivedFrom);
126127
}
127128
}
128129

@@ -176,7 +177,7 @@ static char* calculate_tooltip(const char* type, xmlNodePtr root, uint64_t base_
176177
*/
177178
static void register_registers(xmlNodePtr root) {
178179
xmlNodePtr child;
179-
const char* type = root->name ?: "?";
180+
const char* type = (root->type == XML_ELEMENT_NODE) ? root->name : "?";
180181
if (root->type == XML_ELEMENT_NODE && strcmp(type, "register") == 0) {
181182
xmlChar* xml_name = child_element_text(root, "name");
182183
if (xml_name) {
@@ -224,7 +225,9 @@ static void traverse(xmlNodePtr root, GtkTreeIter* store_parent, uint64_t base_a
224225
GtkTreeIter iter;
225226
gtk_tree_store_append(store, &iter, store_parent);
226227
if (strcmp(type, "registers") == 0) {
227-
gtk_tree_view_expand_to_path(tree_view, gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter));
228+
GtkTreePath* tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter);
229+
gtk_tree_view_expand_to_path(tree_view, tree_path);
230+
gtk_tree_path_free(tree_path);
228231
}
229232
{
230233
char* x_tooltip = g_markup_escape_text(g_strchug(tooltip), -1);

0 commit comments

Comments
 (0)