Skip to content

Commit

Permalink
Fix assertion failure parsing invalid physical literal
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jul 23, 2023
1 parent fdc75c2 commit fceb07d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions test/test_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fceb07d

Please sign in to comment.