Handle NULL version pointer

This commit is contained in:
Rodrigo Arias 2022-12-16 12:47:19 +01:00
parent 7c7ba729f5
commit ee462d92e8
2 changed files with 6 additions and 0 deletions

View File

@ -14,6 +14,11 @@ version_parse(const char *version, int tuple[3])
{ {
char buf[64]; char buf[64];
if (version == NULL) {
err("parse_version: version is NULL\n");
return -1;
}
if (strlen(version) >= 64) { if (strlen(version) >= 64) {
err("parse_version: version too long: %s\n", version); err("parse_version: version too long: %s\n", version);
return -1; return -1;

View File

@ -21,6 +21,7 @@ int main(void)
{ -1, "1", { 0, 0, 0 } }, { -1, "1", { 0, 0, 0 } },
{ -1, "1.O.O", { 0, 0, 0 } }, { -1, "1.O.O", { 0, 0, 0 } },
{ -1, "1.2.3rc", { 0, 0, 0 } }, { -1, "1.2.3rc", { 0, 0, 0 } },
{ -1, NULL, { 0, 0, 0 } },
}; };
int n = sizeof(cases) / sizeof(cases[0]); int n = sizeof(cases) / sizeof(cases[0]);