]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add one more check for use-after-free prevention
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Sep 2021 13:49:25 +0000 (14:49 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 13 Sep 2021 13:49:25 +0000 (14:49 +0100)
src/libutil/upstream.c

index 98e766194ac355527b38f171f1a0408b8bc20142..8c194eb7974303f47f42068b241500adc2b27c54 100644 (file)
@@ -775,7 +775,7 @@ rspamd_upstream_fail (struct upstream *upstream,
                        upstream->name,
                        reason);
 
-       if (upstream->ctx && upstream->active_idx != -1) {
+       if (upstream->ctx && upstream->active_idx != -1 && upstream->ls) {
                sec_cur = rspamd_get_ticks (FALSE);
 
                RSPAMD_UPSTREAM_LOCK (upstream);
@@ -885,7 +885,7 @@ rspamd_upstream_ok (struct upstream *upstream)
        struct upstream_list_watcher *w;
 
        RSPAMD_UPSTREAM_LOCK (upstream);
-       if (upstream->errors > 0 && upstream->active_idx != -1) {
+       if (upstream->errors > 0 && upstream->active_idx != -1 && upstream->ls) {
                /* We touch upstream if and only if it is active */
                msg_debug_upstream ("reset errors on upstream %s (was %ud)", upstream->name, upstream->errors);
                upstream->errors = 0;