brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 0b9820e Raw
59 lines · c
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -verify %s2// expected-no-diagnostics3 4typedef struct {5    char I[4];6    int S;7} Hdr;8typedef struct {9    short w;10} Hdr2;11typedef struct {12    Hdr2 usedtobeundef;13} Info;14typedef struct {15    const unsigned char *ib;16    int cur;17    int end;18} IB;19unsigned long gl(IB *input);20inline void gbs(IB *input, unsigned char *buf, int count);21void getB(IB *st, Hdr2 *usedtobeundef);22inline unsigned char gb(IB *input) {23    if (input->cur + 1 > input->end)24      ;25    return input->ib[(input->cur)++];26}27static 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}33static void getH(IB *st, Hdr *header) {34    getID (st, header->I);35    header->S = gl(st);36}37static 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}51int 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