From fceb07dd4c456d758f50969b1b3d7448d0488a40 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 22 Jul 2023 18:13:20 +0100 Subject: [PATCH] Fix assertion failure parsing invalid physical literal --- src/common.c | 3 +++ test/test_value.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/common.c b/src/common.c index 566df0f44..4ce440a51 100644 --- a/src/common.c +++ b/src/common.c @@ -368,6 +368,9 @@ bool parse_value(type_t type, const char *str, parsed_value_t *value) *p = toupper_iso88591(*p); *p = '\0'; + if (p == copy) + return false; + ident_t id = ident_new(copy); value->integer = -1; diff --git a/test/test_value.c b/test/test_value.c index d8688f6f0..e29b10aae 100644 --- a/test/test_value.c +++ b/test/test_value.c @@ -180,6 +180,8 @@ START_TEST(test_physical) fail_unless(parse_value(t, " 3 ps ", &v)); ck_assert_int_eq(v.integer, 3000); + + fail_if(parse_value(t, " 5", &v)); } END_TEST