Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyses/memOutOfBounds.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ struct
`Index (ID.top (), convert_offset ofs)
| Index (exp, ofs) ->
let i = match man.ask (Queries.EvalInt exp) with
| `Lifted x -> x
| `Lifted x -> ID.cast_to (Cilfacade.ptrdiff_ikind ()) x
| _ -> ID.top_of @@ Cilfacade.ptrdiff_ikind ()
in
`Index (i, convert_offset ofs)
Expand Down
21 changes: 21 additions & 0 deletions tests/regression/74-invalid_deref/33-enum-in-index.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//PARAM: --set ana.activated[+] memOutOfBounds
//NOCRASH (had invalid ikind exceptions earlier)
#include <stdlib.h>

typedef enum {
ITEM_PREV,
ITEM_NEXT
} direction_t;

struct s {
int head[2];
};


int main()
{
struct s* item = malloc(sizeof(struct s));
direction_t link_field = ITEM_NEXT;
item->head[link_field] = 0;
return 0;
}
Loading