From ee462d92e8dea0755f13684ad583ffe6fc75f14c Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 16 Dec 2022 12:47:19 +0100 Subject: [PATCH] Handle NULL version pointer --- src/include/version.h | 5 +++++ test/unit/version.c | 1 + 2 files changed, 6 insertions(+) diff --git a/src/include/version.h b/src/include/version.h index 3eccde3..d1486c4 100644 --- a/src/include/version.h +++ b/src/include/version.h @@ -14,6 +14,11 @@ version_parse(const char *version, int tuple[3]) { char buf[64]; + if (version == NULL) { + err("parse_version: version is NULL\n"); + return -1; + } + if (strlen(version) >= 64) { err("parse_version: version too long: %s\n", version); return -1; diff --git a/test/unit/version.c b/test/unit/version.c index 105c24e..270b6f4 100644 --- a/test/unit/version.c +++ b/test/unit/version.c @@ -21,6 +21,7 @@ int main(void) { -1, "1", { 0, 0, 0 } }, { -1, "1.O.O", { 0, 0, 0 } }, { -1, "1.2.3rc", { 0, 0, 0 } }, + { -1, NULL, { 0, 0, 0 } }, }; int n = sizeof(cases) / sizeof(cases[0]);