git » libfiu » commit bb09361

libfiu: Make sure either get_func_start() or get_func_end() work

author Alberto Bertogli
2017-09-04 23:36:47 UTC
committer Alberto Bertogli
2017-09-04 23:55:36 UTC
parent f41f906cf4ae051537e373f564c1650e8e324f67

libfiu: Make sure either get_func_start() or get_func_end() work

We need either get_func_start() or get_func_end() in order to do the
stack checks. Make sure at least one is available.

libfiu/fiu.c +5 -3

diff --git a/libfiu/fiu.c b/libfiu/fiu.c
index fd71815..4f9de64 100644
--- a/libfiu/fiu.c
+++ b/libfiu/fiu.c
@@ -430,14 +430,16 @@ int fiu_enable_stack(const char *name, int failnum, void *failinfo,
 	if (backtrace_works((void (*)()) fiu_enable_stack) == 0)
 		return -1;
 
+	// We need either get_func_end() or get_func_start() to work, see
+	// pc_in_func() above.
+	if (get_func_end(func) == NULL && get_func_start(func) == NULL)
+		return -1;
+
 	pf = pf_create(name, failnum, failinfo, flags, PF_STACK);
 	if (pf == NULL)
 		return -1;
 
 	pf->minfo.stack.func_start = func;
-
-	/* Note get_func_end(func) can return NULL and we would still be able
-	 * to make it work, see pc_in_func() above. */
 	pf->minfo.stack.func_end = get_func_end(func);
 	pf->minfo.stack.func_pos_in_stack = func_pos_in_stack;
 	return insert_pf(pf);