1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04:00

Fix bug 944: avoid duplicate type-query handlers

Previously, init_type_query would check to make sure that it doesn't create a
duplicate type query and would return NULL if it otherwise would create a
duplicate.  Then setup_download_handler would return 0 to do_move.

This patch changes setup_download_handler to return 1 to do_move in this
situation so that do_move stops trying to load the document.

This avoid a crash when loading twice the same file in the same tab when
loading the file opens a type query.
This commit is contained in:
Miciah Dashiel Butler Masters 2008-05-11 15:42:21 +00:00
parent 0b2edbd33a
commit 9e04b0ec8c

View File

@ -969,17 +969,24 @@ continue_download(void *data, unsigned char *file)
}
static struct type_query *
find_type_query(struct session *ses)
{
struct type_query *type_query;
foreach (type_query, ses->type_queries)
if (compare_uri(type_query->uri, ses->loading_uri, 0))
return type_query;
return NULL;
}
static struct type_query *
init_type_query(struct session *ses, struct download *download,
struct cache_entry *cached)
{
struct type_query *type_query;
/* There can be only one ... */
foreach (type_query, ses->type_queries)
if (compare_uri(type_query->uri, ses->loading_uri, 0))
return NULL;
type_query = mem_calloc(1, sizeof(*type_query));
if (!type_query) return NULL;
@ -1331,6 +1338,10 @@ setup_download_handler(struct session *ses, struct download *loading,
if (!handler && strlen(ctype) >= 4 && !strncasecmp(ctype, "text", 4))
goto plaintext_follow;
type_query = find_type_query(ses);
if (type_query) {
ret = 1;
} else {
type_query = init_type_query(ses, loading, cached);
if (type_query) {
ret = 1;
@ -1346,6 +1357,7 @@ setup_download_handler(struct session *ses, struct download *loading,
#endif
do_type_query(type_query, ctype, handler);
}
}
mem_free_if(handler);