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

NET: Ensure that move_download sets new->conn to NULL when in result state

When in result state the connection might already have been freed.
This commit is contained in:
Jonas Fonseca 2006-02-07 02:02:33 +01:00 committed by Jonas Fonseca
parent ac1231ef2f
commit 0d53158553

View File

@ -1021,7 +1021,7 @@ void
move_download(struct download *old, struct download *new,
enum connection_priority newpri)
{
struct connection *conn = old->conn;
struct connection *conn;
assert(old);
@ -1029,7 +1029,9 @@ move_download(struct download *old, struct download *new,
* example the file protocol loads it's object immediately. This is
* catched by the result state check below. */
new->conn = old->conn;
conn = old->conn;
new->conn = conn;
new->cached = old->cached;
new->prev_error = old->prev_error;
new->progress = old->progress;
@ -1037,8 +1039,12 @@ move_download(struct download *old, struct download *new,
new->pri = newpri;
if (is_in_result_state(old->state)) {
if (new->callback)
/* Ensure that new->conn is always "valid", that is NULL if the
* connection has been detached and non-NULL otherwise. */
if (new->callback) {
new->conn = NULL;
new->callback(new, new->data);
}
return;
}