From a2bc3973502672778e8c9cd16b35bf5bab02adbe Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 1 Dec 2007 19:31:23 +0000 Subject: [PATCH] Fix NULL-dereference in document_info_dialog if document not yet loaded It was possible to cause a crash by opening the Document Info box at the right moment during the loading of a document. --- src/dialogs/document.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/dialogs/document.c b/src/dialogs/document.c index 25a57bc0..062ccac7 100644 --- a/src/dialogs/document.c +++ b/src/dialogs/document.c @@ -142,7 +142,6 @@ document_info_dialog(struct session *ses) struct terminal *term = ses->tab->term; struct location *location = cur_loc(ses); struct document_view *doc_view; - struct cache_entry *cached; struct string msg; if (!location) { @@ -169,8 +168,8 @@ document_info_dialog(struct session *ses) add_char_to_string(&msg, '\n'); - cached = doc_view->document->cached; - if (cached) { + if (doc_view && doc_view->document->cached) { + struct cache_entry *cached = doc_view->document->cached; unsigned char *a; add_format_to_string(&msg, "\n%s: %" OFF_T_FORMAT,