diff --git a/src/semver.c b/src/semver.c index 85d1c2f..d63da30 100644 --- a/src/semver.c +++ b/src/semver.c @@ -214,12 +214,12 @@ semver* parse_semver(char* str, bool lax, bool throw, bool* bad) { if (i >= 1 && (i == 1 || patch[i-2] == '.') && patch[i-1] == '0' && isdigit(next)) { pred = true; // Numeric identifiers must not include a leading 0. Scan ahead. - for (p = i; p < strlen(patch); p++) { - if (patch[p] == '.') { + for (p = atchar; p < len; p++) { + if (str[p] == '.') { // We got to the end of this bit. break; } - if (isalpha(patch[p]) || patch[p] == '-') { + if (isalpha(str[p]) || str[p] == '-') { // If there is a letter or a dash, it's okay to start with a leading 0. pred = false; break; diff --git a/test/sql/corpus.sql b/test/sql/corpus.sql index 0018a10..c0fe98e 100644 --- a/test/sql/corpus.sql +++ b/test/sql/corpus.sql @@ -6,7 +6,7 @@ BEGIN; \i test/pgtap-core.sql CREATE EXTENSION semver; -SELECT plan(75); +SELECT plan(76); --SELECT * FROM no_plan(); -- Valid Semantic Versions @@ -47,7 +47,8 @@ SELECT lives_ok( '1.0.0-0010-1234', '1.0.0-1.2.3-1234', '1.0.0-1234', - '1.0.0-4321' + '1.0.0-4321', + '0.0.0-00010101000000-000000000000' -- ]) AS v;