Avoid that iscsi_reconnect() crashes

In the else branch, set the tmp_iscsi->old_iscsi pointer instead of the
iscsi->old_iscsi pointer.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
This commit is contained in:
Bart Van Assche
2018-10-22 16:31:55 -07:00
parent a15c2a5c61
commit 663aad13ba

View File

@@ -457,7 +457,7 @@ int iscsi_reconnect(struct iscsi_context *iscsi)
}
tmp_iscsi->old_iscsi = iscsi->old_iscsi;
} else {
iscsi->old_iscsi = malloc(sizeof(struct iscsi_context));
tmp_iscsi->old_iscsi = malloc(sizeof(struct iscsi_context));
memcpy(tmp_iscsi->old_iscsi, iscsi, sizeof(struct iscsi_context));
}
memcpy(iscsi, tmp_iscsi, sizeof(struct iscsi_context));