Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 2e05c822 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

FIX: Change the checks in reg {get,func} to not SEGV when the register don't have the asked module

parent daa32549
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!191Resolve "BUG: segfault when the module specified in the config is not present"
...@@ -22,8 +22,7 @@ reg_global(struct module_reg **reg_ptr) ...@@ -22,8 +22,7 @@ reg_global(struct module_reg **reg_ptr)
PRIVATE_FUNCTION void * PRIVATE_FUNCTION void *
__reg_get(struct module_reg *reg, const char *name) __reg_get(struct module_reg *reg, const char *name)
{ {
int i; for (int i = 0; (reg + i) && (reg + i)->name && (reg + i)->obj; ++i) {
for (i = 0; (reg + i)->name && (reg + i)->obj; ++i) {
if (STR_MATCH((reg + i)->name, name)) if (STR_MATCH((reg + i)->name, name))
return (reg + i)->obj; return (reg + i)->obj;
} }
...@@ -33,8 +32,7 @@ __reg_get(struct module_reg *reg, const char *name) ...@@ -33,8 +32,7 @@ __reg_get(struct module_reg *reg, const char *name)
PRIVATE_FUNCTION reg_func PRIVATE_FUNCTION reg_func
__reg_func(struct module_reg *reg, const char *name) __reg_func(struct module_reg *reg, const char *name)
{ {
int i; for (int i = 0; (reg + i) && (reg + i)->name && (reg + i)->func; ++i) {
for (i = 0; (reg + i)->name && (reg + i)->func; ++i) {
if (STR_MATCH((reg + i)->name, name)) if (STR_MATCH((reg + i)->name, name))
return (reg + i)->func; return (reg + i)->func;
} }
...@@ -44,7 +42,8 @@ __reg_func(struct module_reg *reg, const char *name) ...@@ -44,7 +42,8 @@ __reg_func(struct module_reg *reg, const char *name)
PRIVATE_FUNCTION void * PRIVATE_FUNCTION void *
__from_file(const char *file, void **handle, const char *symbol) __from_file(const char *file, void **handle, const char *symbol)
{ {
char *error; void *sym = NULL;
char *error = NULL;
*handle = dlopen(file, RTLD_NOW); *handle = dlopen(file, RTLD_NOW);
if (NULL == *handle) { if (NULL == *handle) {
...@@ -53,9 +52,10 @@ __from_file(const char *file, void **handle, const char *symbol) ...@@ -53,9 +52,10 @@ __from_file(const char *file, void **handle, const char *symbol)
} }
dlerror(); dlerror();
void *sym = dlsym(*handle, symbol); sym = dlsym(*handle, symbol);
error = dlerror();
if ((error = dlerror()) != NULL) { if (error != NULL) {
LOG_ERROR("REG", "libdl error in dlsym on file '%s': %s\n", file, error); LOG_ERROR("REG", "libdl error in dlsym on file '%s': %s\n", file, error);
return NULL; return NULL;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter