1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
2
3 typedef struct {
4 char I[4];
5 int S;
6 } Hdr;
7 typedef struct {
8 short w;
9 } Hdr2;
10 typedef struct {
11 Hdr2 usedtobeundef;
12 } Info;
13 typedef struct {
14 const unsigned char *ib;
15 int cur;
16 int end;
17 } IB;
18 inline unsigned long gl(IB *input);
19 inline void gbs(IB *input, unsigned char *buf, int count);
20 void getB(IB *st, Hdr2 *usedtobeundef);
gb(IB * input)21 inline unsigned char gb(IB *input) {
22 if (input->cur + 1 > input->end)
23 ;
24 return input->ib[(input->cur)++];
25 }
getID(IB * st,char str[4])26 static void getID(IB *st, char str[4]) {
27 str[0] = gb(st);
28 str[1] = gb(st);
29 str[2] = gb(st);
30 str[3] = gb(st);
31 }
getH(IB * st,Hdr * header)32 static void getH(IB *st, Hdr *header) {
33 getID (st, header->I);
34 header->S = gl(st);
35 }
readILBM(IB * st,Info * pic)36 static void readILBM(IB *st, Info *pic) {
37 // Initialize field;
38 pic->usedtobeundef.w = 5;
39
40 // Time out in the function so that we will be forced to retry with no inlining.
41 Hdr header;
42 getH (st, &header);
43 getID(st, header.I);
44 int i = 0;
45 while (st->cur < st->end && i < 4) {
46 i++;
47 getH (st, &header);
48 }
49 }
bitmapImageRepFromIFF(IB st,const unsigned char * ib,int il)50 int bitmapImageRepFromIFF(IB st, const unsigned char *ib, int il) {
51 Info pic;
52 st.ib = ib;
53 st.cur = 0;
54 st.end = il;
55 readILBM(&st,&pic);
56 return pic.usedtobeundef.w; // No undefined value warning here.
57 }
58