[Forensics-changes] [yara] 06/368: Use assert() instead of abort() in exception.h

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.5.0
in repository yara.

commit e6a1d4c23178fcdf8e64c246510839b5620f8f75
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Mon Jun 29 10:35:57 2015 +0200

    Use assert() instead of abort() in exception.h
    
    With assert() we get information about the line where the program was aborted, and the program can be compiled without those extra checks.
---
 libyara/exception.h | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libyara/exception.h b/libyara/exception.h
index 5c8b54a..f3a2e8c 100644
--- a/libyara/exception.h
+++ b/libyara/exception.h
@@ -17,6 +17,8 @@ limitations under the License.
 #ifndef YR_EXCEPTION_H
 #define YR_EXCEPTION_H
 
+#include <assert.h>
+
 #if _WIN32
 
 #include <windows.h>
@@ -38,8 +40,8 @@ static LONG CALLBACK exception_handler(
     case EXCEPTION_ACCESS_VIOLATION:
       if (tidx != -1 && exc_jmp_buf[tidx] != NULL)
         longjmp(*exc_jmp_buf[tidx], 1);
-      else
-        abort();
+
+      assert(FALSE);  // We should not reach this point.
   }
 
   return EXCEPTION_CONTINUE_SEARCH;
@@ -50,8 +52,7 @@ static LONG CALLBACK exception_handler(
   {                                                                     \
     HANDLE exh = AddVectoredExceptionHandler(1, exception_handler);     \
     int tidx = yr_get_tidx();                                           \
-    if (tidx == -1)                                                     \
-      abort();                                                          \
+    assert(tidx != -1);                                                 \
     jmp_buf jb;                                                         \
     exc_jmp_buf[tidx] = &jb;                                            \
     if (setjmp(jb) == 0)                                                \
@@ -77,8 +78,7 @@ static void exception_handler(int sig) {
     if (tidx != -1 && exc_jmp_buf[tidx] != NULL)
       siglongjmp(*exc_jmp_buf[tidx], 1);
 
-    // We should not reach this point.
-    abort();
+    assert(FALSE);  // We should not reach this point.
   }
 }
 
@@ -96,8 +96,7 @@ typedef struct sigaction sa;
     pthread_sigmask(SIG_SETMASK, &act.sa_mask, &oldmask);       \
     sigaction(SIGBUS, &act, &oldact);                           \
     int tidx = yr_get_tidx();                                   \
-    if (tidx == -1)                                             \
-      abort();                                                  \
+    assert(tidx != -1);                                         \
     sigjmp_buf jb;                                              \
     exc_jmp_buf[tidx] = &jb;                                    \
     if (sigsetjmp(jb, 1) == 0)                                  \

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list