[pacman-dev,1/5] alpm_unlock: check handle before dereferencing

Message ID 20170510225457.18270-1-andrew.gregory.8@gmail.com
State Accepted, archived
Headers show
Series [pacman-dev,1/5] alpm_unlock: check handle before dereferencing | expand

Commit Message

Andrew Gregory May 10, 2017, 10:54 p.m. UTC
Prevents SIGSEGV if we catch SIGINT or SIGHUP before initializing alpm.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 lib/libalpm/handle.c | 1 +
 1 file changed, 1 insertion(+)

Patch

diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 502a5d9e..08625e3a 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -135,6 +135,7 @@  int _alpm_handle_lock(alpm_handle_t *handle)
  */
 int SYMEXPORT alpm_unlock(alpm_handle_t *handle)
 {
+	ASSERT(handle != NULL, return -1);
 	ASSERT(handle->lockfile != NULL, return 0);
 	ASSERT(handle->lockfd >= 0, return 0);