1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

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.
This commit is contained in:
Witold Filipczyk 2008-03-13 22:53:31 +01:00 committed by Kalle Olavi Niemitalo
parent 2aa70f77bc
commit 81f8ee1fa2
3 changed files with 3 additions and 4 deletions

1
src/cache/cache.h vendored
View File

@ -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 */
};

View File

@ -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)) {

View File

@ -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);