diff --git a/Makefile b/Makefile
index e43e2a5ca..07dd7ff9b 100644
--- a/Makefile
+++ b/Makefile
@@ -102,7 +102,7 @@ SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
 VPATH = $(SRCDIR)
 
 # Add git revision and build variant defines
-VERSION := $(shell git describe --tags --abbrev=0 --match v*)
+VERSION := $(shell git describe --tags --abbrev=0 --match 'v*')
 VERSION_NUM := $(shell VERSION=$(VERSION); echo $${VERSION:1})
 
 ifdef CI
diff --git a/lib/api.c b/lib/api.c
index ebca6d24a..5fe95dfa8 100644
--- a/lib/api.c
+++ b/lib/api.c
@@ -150,6 +150,9 @@ int api_http_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void
 			break;
 
 		case LWS_CALLBACK_CLOSED_HTTP:
+			if (!s)
+				return -1;
+
 			ret = api_session_destroy(s);
 			if (ret)
 				return -1;