int main()
{
	gdImagePtr im;
	FILE *fp;
	char path[1024];

	/* Read the corrupt image. */
	sprintf(path, "%s/gd2/invalid_neg_size.gd2", GDTEST_TOP_DIR);
	fp = fopen(path, "rb");
	if (!fp) {
		printf("failed, cannot open file\n");
		return 1;
	}
	im = gdImageCreateFromGd2(fp);
	fclose(fp);

	/* Should have failed & rejected it. */
	return im == NULL ? 0 : 1;
}
When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.