Skip to content

Commit 29c2ce2

Browse files
committed
Make sure we clear error cache in various places just in case.
1 parent a9f8c6f commit 29c2ce2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core/types.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ static infix_status _create_aggregate_setup(infix_arena_t * arena,
393393
c23_nodiscard infix_status infix_type_create_pointer_to(infix_arena_t * arena,
394394
infix_type ** out_type,
395395
infix_type * pointee_type) {
396+
_infix_clear_error();
396397
if (!out_type || !pointee_type) {
397398
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
398399
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -424,6 +425,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_array(infix_arena_t * are
424425
infix_type ** out_type,
425426
infix_type * element_type,
426427
size_t num_elements) {
428+
_infix_clear_error();
427429
if (out_type == nullptr || element_type == nullptr) {
428430
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
429431
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -461,6 +463,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_array(infix_arena_t * are
461463
INFIX_API c23_nodiscard infix_status infix_type_create_flexible_array(infix_arena_t * arena,
462464
infix_type ** out_type,
463465
infix_type * element_type) {
466+
_infix_clear_error();
464467
if (out_type == nullptr || element_type == nullptr) {
465468
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
466469
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -504,6 +507,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_flexible_array(infix_aren
504507
INFIX_API c23_nodiscard infix_status infix_type_create_enum(infix_arena_t * arena,
505508
infix_type ** out_type,
506509
infix_type * underlying_type) {
510+
_infix_clear_error();
507511
if (out_type == nullptr || underlying_type == nullptr) {
508512
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
509513
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -538,6 +542,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_enum(infix_arena_t * aren
538542
INFIX_API c23_nodiscard infix_status infix_type_create_complex(infix_arena_t * arena,
539543
infix_type ** out_type,
540544
infix_type * base_type) {
545+
_infix_clear_error();
541546
if (out_type == nullptr || base_type == nullptr || (!is_float(base_type) && !is_double(base_type))) {
542547
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
543548
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -569,6 +574,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_vector(infix_arena_t * ar
569574
infix_type ** out_type,
570575
infix_type * element_type,
571576
size_t num_elements) {
577+
_infix_clear_error();
572578
if (out_type == nullptr || element_type == nullptr || element_type->category != INFIX_TYPE_PRIMITIVE) {
573579
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
574580
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -607,6 +613,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_union(infix_arena_t * are
607613
infix_type ** out_type,
608614
infix_struct_member * members,
609615
size_t num_members) {
616+
_infix_clear_error();
610617
infix_type * type = nullptr;
611618
infix_struct_member * arena_members = nullptr;
612619
infix_status status = _create_aggregate_setup(arena, &type, &arena_members, members, num_members);
@@ -715,6 +722,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_packed_struct(infix_arena
715722
size_t alignment,
716723
infix_struct_member * members,
717724
size_t num_members) {
725+
_infix_clear_error();
718726
if (out_type == nullptr || (num_members > 0 && members == nullptr)) {
719727
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
720728
return INFIX_ERROR_INVALID_ARGUMENT;
@@ -770,6 +778,7 @@ INFIX_API c23_nodiscard infix_status infix_type_create_named_reference(infix_are
770778
infix_type ** out_type,
771779
const char * name,
772780
infix_aggregate_category_t agg_cat) {
781+
_infix_clear_error();
773782
if (out_type == nullptr || name == nullptr) {
774783
_infix_set_error(INFIX_CATEGORY_GENERAL, INFIX_CODE_NULL_POINTER, 0);
775784
return INFIX_ERROR_INVALID_ARGUMENT;

t/011_bitfields.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST {
3535
plan(1);
3636
subtest("Basic Bitfields") {
3737
plan(8);
38-
infix_arena_t * arena = infix_arena_create(2048);
38+
infix_arena_t * arena = NULL;
3939

4040
// signature: "{a: uint32:3, b: uint32:5, c: uint32:8, d: uint32:1}"
4141
const char * sig = "{a: uint32:3, b: uint32:5, c: uint32:8, d: uint32:1}";

0 commit comments

Comments
 (0)