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