From 81f8ee1fa2b94ef40460eb4a42710e1ed9e22c98 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Thu, 13 Mar 2008 22:53:31 +0100 Subject: [PATCH] bug 991: fix crash when the file is already cached If the user opens the same file again after it is in the cache, then ELinks does not always open a new connection, so download->conn can be NULL in init_type_query(), and download->conn->cgi would crash. Don't read that, then; instead add a new flag cache_entry.cgi, which http_got_header() sets or clears as soon as possible after the cache entry has been created. --- src/cache/cache.h | 1 + src/protocol/http/http.c | 1 + src/session/download.c | 5 +---- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cache/cache.h b/src/cache/cache.h index 8ee0ad6c..ed68d1fe 100644 --- a/src/cache/cache.h +++ b/src/cache/cache.h @@ -63,6 +63,7 @@ struct cache_entry { * the cache_entry should be busted or not. You are not likely to see * an entry with this set to 1 in wild nature ;-). */ unsigned int gc_target:1; /* The GC touch of death */ + unsigned int cgi:1; /* Is a CGI output? */ enum cache_mode cache_mode; /* Reload condition */ }; diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 2042cd2c..260754fb 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -1587,6 +1587,7 @@ again: abort_connection(conn, S_OUT_OF_MEM); return; } + conn->cached->cgi = conn->cgi; mem_free_set(&conn->cached->head, head); if (!get_opt_bool("document.cache.ignore_cache_control", NULL)) { diff --git a/src/session/download.c b/src/session/download.c index 2c7b2cde..e2b5d70d 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -975,9 +975,6 @@ init_type_query(struct session *ses, struct download *download, { struct type_query *type_query; - assert(download && download->conn); - if_assert_failed return NULL; - /* There can be only one ... */ foreach (type_query, ses->type_queries) if (compare_uri(type_query->uri, ses->loading_uri, 0)) @@ -991,7 +988,7 @@ init_type_query(struct session *ses, struct download *download, type_query->target_frame = null_or_stracpy(ses->task.target.frame); type_query->cached = cached; - type_query->cgi = download->conn->cgi; + type_query->cgi = cached->cgi; object_lock(type_query->cached); move_download(download, &type_query->download, PRI_MAIN); -- 2.11.4.GIT