]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix crash on start introduced by 181ae63889075fd475f007c62eabc78ac9e83265
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 10 Dec 2022 15:55:42 +0000 (09:55 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 10 Dec 2022 17:28:49 +0000 (11:28 -0600)
src/lib/util/dl.c

index fb6085c89c21c89239d15a157152a55bee8bb520..5a94f826e0566f26b916e95150a943b6e54bd454 100644 (file)
@@ -523,13 +523,12 @@ dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name, void *uctx, bool uctx
        if (search_path) {
                char *ctx, *paths, *path;
                char *p;
+               char *dlerror_txt = NULL;
 
                fr_strerror_clear();
 
                ctx = paths = talloc_typed_strdup(NULL, search_path);
                while ((path = strsep(&paths, ":")) != NULL) {
-                       char *dlerror_txt;
-
                        /*
                         *      Trim the trailing slash
                         */
@@ -592,7 +591,12 @@ dl_t *dl_by_name(dl_loader_t *dl_loader, char const *name, void *uctx, bool uctx
                 */
                if (!handle) {
                        talloc_free(ctx);
-                       fr_strerror_printf("%s", dlerror());
+                       /*
+                        *      We're reliant on dlerror_txt from the loop,
+                        *      because once dlerror() is called the error
+                        *      is cleared.
+                        */
+                       fr_strerror_printf("%s", dlerror_txt ? dlerror_txt : "unknown dlopen error");
                        return NULL;
                }