From 1bc79cb9a5067d685ba507fad9b189ed28ad70a0 Mon Sep 17 00:00:00 2001
From: Andrew Gregory <andrew.gregory.8@gmail.com>
Date: Wed, 10 May 2017 18:54:53 -0400
Subject: alpm_unlock: check handle before dereferencing

Prevents SIGSEGV if we catch SIGINT or SIGHUP before initializing alpm.

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

(limited to 'lib')

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);
 
-- 
cgit v1.2.3-70-g09d2