aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/deref-before-check-macro-pr108745.c
blob: 92f5a02645de7741ed797e84feea5b6bbcb4f499 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Reduced from ImageMagick-7.1.0-57.  */

#define NULL ((void *)0)

typedef __builtin_va_list va_list;
typedef __SIZE_TYPE__ size_t;

typedef struct _ExceptionInfo ExceptionInfo;

void
ThrowMagickException(ExceptionInfo*,
		     const char*,
		     const char*,
		     ...) __attribute__((__format__(__printf__, 3, 4)));

typedef struct _Image
{
  /* [...snip...] */
  size_t columns, rows, depth, colors;
  /* [...snip...] */
} Image;

typedef struct _ImageInfo
{
  /* [...snip...] */
  char filename[4096];
  /* [...snip...] */
} ImageInfo;

extern Image *AcquireImage(const ImageInfo*, ExceptionInfo*);
extern void CloseBlob(Image*);
extern Image *DestroyImageList(Image*);

#define ThrowReaderException(tag) \
{ \
  (void) ThrowMagickException(exception, tag, \
    "`%s'",image_info->filename); \
  if ((image) != (Image *) NULL) \
    { \
      (void) CloseBlob(image); \
      image=DestroyImageList(image); \
    } \
  return((Image *) NULL); \
}

Image*
ReadMAPImage(const ImageInfo* image_info, ExceptionInfo* exception)
{
  Image* image;
  image = AcquireImage(image_info, exception);
  if ((image->columns == 0) || (image->rows == 0))
    ThrowReaderException("MustSpecifyImageSize");
  return image;
}