mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05: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:
parent
0b2edbd33a
commit
9e04b0ec8c
@ -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 *
|
static struct type_query *
|
||||||
init_type_query(struct session *ses, struct download *download,
|
init_type_query(struct session *ses, struct download *download,
|
||||||
struct cache_entry *cached)
|
struct cache_entry *cached)
|
||||||
{
|
{
|
||||||
struct type_query *type_query;
|
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));
|
type_query = mem_calloc(1, sizeof(*type_query));
|
||||||
if (!type_query) return NULL;
|
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))
|
if (!handler && strlen(ctype) >= 4 && !strncasecmp(ctype, "text", 4))
|
||||||
goto plaintext_follow;
|
goto plaintext_follow;
|
||||||
|
|
||||||
|
type_query = find_type_query(ses);
|
||||||
|
if (type_query) {
|
||||||
|
ret = 1;
|
||||||
|
} else {
|
||||||
type_query = init_type_query(ses, loading, cached);
|
type_query = init_type_query(ses, loading, cached);
|
||||||
if (type_query) {
|
if (type_query) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
@ -1346,6 +1357,7 @@ setup_download_handler(struct session *ses, struct download *loading,
|
|||||||
#endif
|
#endif
|
||||||
do_type_query(type_query, ctype, handler);
|
do_type_query(type_query, ctype, handler);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mem_free_if(handler);
|
mem_free_if(handler);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user