Skip to content

Commit 2b7ab2b

Browse files
Correctly cast offsets to Cilfacade.ptrdiff_ikind () in memOutOfBounds
1 parent 8dd4762 commit 2b7ab2b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/analyses/memOutOfBounds.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ struct
174174
`Index (ID.top (), convert_offset ofs)
175175
| Index (exp, ofs) ->
176176
let i = match man.ask (Queries.EvalInt exp) with
177-
| `Lifted x -> x
177+
| `Lifted x -> ID.cast_to (Cilfacade.ptrdiff_ikind ()) x
178178
| _ -> ID.top_of @@ Cilfacade.ptrdiff_ikind ()
179179
in
180180
`Index (i, convert_offset ofs)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//PARAM: --set ana.activated[+] memOutOfBounds
2+
//NOCRASH (had invalid ikind exceptions earlier)
3+
#include <stdlib.h>
4+
5+
typedef enum {
6+
ITEM_PREV,
7+
ITEM_NEXT
8+
} direction_t;
9+
10+
struct s {
11+
int head[2];
12+
};
13+
14+
15+
int main()
16+
{
17+
struct s* item = malloc(sizeof(struct s));
18+
direction_t link_field = ITEM_NEXT;
19+
item->head[link_field] = 0;
20+
return 0;
21+
}

0 commit comments

Comments
 (0)