]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Re-sequence code to check before dereference (CID #1681438)
authorNick Porter <nick@portercomputing.co.uk>
Fri, 20 Feb 2026 08:54:58 +0000 (08:54 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 20 Feb 2026 11:06:17 +0000 (11:06 +0000)
src/lib/io/schedule.c

index c5f1cd438ac41f4b5b84c6ab2443a93a7727fd58..1f767e9ea5ef14dfa037ab432ef7e5504f572707 100644 (file)
@@ -482,11 +482,26 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el,
                return NULL;
        }
 
-       sc->config = config;
+       /*
+        *      Parse any scheduler-specific configuration.
+        */
+       if (!config) {
+               MEM(sc->config = talloc_zero(sc, fr_schedule_config_t));
+               sc->config->max_networks = 1;
+               sc->config->max_workers = 4;
+       } else {
+               sc->config = config;
+
+               if (sc->config->max_networks < 1) sc->config->max_networks = 1;
+               if (sc->config->max_networks > 64) sc->config->max_networks = 64;
+               if (sc->config->max_workers < 1) sc->config->max_workers = 1;
+               if (sc->config->max_workers > 64) sc->config->max_workers = 64;
+       }
+
        sc->el = el;
        sc->log = logger;
        sc->lvl = lvl;
-       sc->cs = config->cs;
+       sc->cs = sc->config->cs;
 
        sc->worker_thread_instantiate = worker_thread_instantiate;
        sc->worker_thread_detach = worker_thread_detach;
@@ -568,22 +583,6 @@ fr_schedule_t *fr_schedule_create(TALLOC_CTX *ctx, fr_event_list_t *el,
                return sc;
        }
 
-       /*
-        *      Parse any scheduler-specific configuration.
-        */
-       if (!config) {
-               MEM(sc->config = talloc_zero(sc, fr_schedule_config_t));
-               sc->config->max_networks = 1;
-               sc->config->max_workers = 4;
-       } else {
-               sc->config = config;
-
-               if (sc->config->max_networks < 1) sc->config->max_networks = 1;
-               if (sc->config->max_networks > 64) sc->config->max_networks = 64;
-               if (sc->config->max_workers < 1) sc->config->max_workers = 1;
-               if (sc->config->max_workers > 64) sc->config->max_workers = 64;
-       }
-
        /*
         *      Create the lists which hold the workers and networks.
         */