Prevent possible null pointer dereference

This commit is contained in:
Moritz Lipp 2012-04-01 11:38:38 +02:00
parent 2918d92280
commit 7a9c7d762c

View file

@ -160,11 +160,13 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list))
GString* string = g_string_new(NULL); GString* string = g_string_new(NULL);
GIRARA_LIST_FOREACH(information, zathura_document_information_entry_t*, iter, entry) GIRARA_LIST_FOREACH(information, zathura_document_information_entry_t*, iter, entry)
for (unsigned int i = 0; i < LENGTH(meta_fields); i++) { if (entry != NULL) {
if (meta_fields[i].field == entry->type) { for (unsigned int i = 0; i < LENGTH(meta_fields); i++) {
char* text = g_strdup_printf("<b>%s:</b> %s\n", meta_fields[i].name, entry->value); if (meta_fields[i].field == entry->type) {
g_string_append(string, text); char* text = g_strdup_printf("<b>%s:</b> %s\n", meta_fields[i].name, entry->value);
g_free(text); g_string_append(string, text);
g_free(text);
}
} }
} }
GIRARA_LIST_FOREACH_END(information, zathura_document_information_entry_t*, iter, entry); GIRARA_LIST_FOREACH_END(information, zathura_document_information_entry_t*, iter, entry);