File: bug_289.c

package info (click to toggle)
libgd2 2.3.3-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,396 kB
  • sloc: ansic: 49,708; sh: 5,660; javascript: 1,859; cpp: 1,308; makefile: 345; perl: 197; tcl: 45
file content (35 lines) | stat: -rw-r--r-- 855 bytes parent folder | download | duplicates (3)
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
/**
 * Passing an unrecognized format to gdImageGd2() should result in
 * GD2_FMT_TRUECOLOR_COMPRESSED for truecolor images.
 *
 * See <https://github.com/libgd/libgd/issues/289>.
 */

#include "gd.h"
#include "gdtest.h"


#define GD2_FMT_UNRECOGNIZED 0
#define GD2_FMT_TRUECOLOR_COMPRESSED 4

#define MSG "expected %s byte to be %d, but got %d\n"


int main()
{
    gdImagePtr im;
    char *buffer;
    int size;

    im = gdImageCreateTrueColor(10, 10);
    gdTestAssert(im != NULL);
    buffer = (char *) gdImageGd2Ptr(im, 128, GD2_FMT_UNRECOGNIZED, &size);
    gdTestAssert(buffer != NULL);
    gdImageDestroy(im);
    gdTestAssertMsg(buffer[12] == 0, MSG, "1st", 0, buffer[12]);
    gdTestAssertMsg(buffer[13] == GD2_FMT_TRUECOLOR_COMPRESSED, MSG, "2nd", GD2_FMT_TRUECOLOR_COMPRESSED, buffer[13]);

    gdFree(buffer);

    return gdNumFailures();
}