From 7a9c7d762cda33c10d0809271dbf323c795633a6 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Sun, 1 Apr 2012 11:38:38 +0200 Subject: [PATCH] Prevent possible null pointer dereference --- commands.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/commands.c b/commands.c index e2b4dbf..9ee4c70 100644 --- a/commands.c +++ b/commands.c @@ -160,11 +160,13 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list)) GString* string = g_string_new(NULL); GIRARA_LIST_FOREACH(information, zathura_document_information_entry_t*, iter, entry) - for (unsigned int i = 0; i < LENGTH(meta_fields); i++) { - if (meta_fields[i].field == entry->type) { - char* text = g_strdup_printf("%s: %s\n", meta_fields[i].name, entry->value); - g_string_append(string, text); - g_free(text); + if (entry != NULL) { + for (unsigned int i = 0; i < LENGTH(meta_fields); i++) { + if (meta_fields[i].field == entry->type) { + char* text = g_strdup_printf("%s: %s\n", meta_fields[i].name, entry->value); + g_string_append(string, text); + g_free(text); + } } } GIRARA_LIST_FOREACH_END(information, zathura_document_information_entry_t*, iter, entry);