summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-05-11 17:13:11 -0300
committerAndrés <andmarti@gmail.com>2021-05-11 17:13:11 -0300
commit2f1d852b9c34b1bbb4a80a872988b2906caa1739 (patch)
tree7863272be25f870c93293d35829ac1b5af6f93c7
parent26afee1152212f82149c7e44e1ab9d59b701f1ba (diff)
trigger: Avoid segfault when not being able to load module. #325
-rw-r--r--src/trigger.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/trigger.c b/src/trigger.c
index af7b4dc..ab035d5 100644
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -141,16 +141,16 @@ void set_trigger(int r, int c, int rf, int cf, char * str) {
tmp |= TRG_C;
sprintf(buffer, "module/%s", n->trigger->file);
- if(plugin_exists(buffer,strlen(buffer),buffer1))
- n->trigger->handle=dlopen(buffer1,RTLD_LAZY);
- if(!n->trigger->handle) {
- fputs (dlerror(), stderr);
- exit(1);
+ if (plugin_exists(buffer, strlen(buffer), buffer1))
+ n->trigger->handle = dlopen(buffer1, RTLD_LAZY);
+ if (! n->trigger->handle) {
+ sc_error("Trigger could not be set: %s", dlerror());
+ return;
}
n->trigger->c_function = dlsym(n->trigger->handle, n->trigger->function);
if ((error = dlerror()) != NULL) {
- fputs(error, stderr);
- exit(1);
+ sc_error("Trigger could not be set: %s.", error);
+ return;
}
}
n->trigger->flag = tmp;