solved a bug that reading a damaged JPEG will shut the program down

This commit is contained in:
chenjiahe 2019-07-24 18:35:11 +08:00
parent 61c9d02ec4
commit bd81ec4931
1 changed files with 3 additions and 2 deletions

View File

@ -1295,8 +1295,9 @@ image load_image_stb(char *filename, int channels)
int w, h, c;
unsigned char *data = stbi_load(filename, &w, &h, &c, channels);
if (!data) {
fprintf(stderr, "Cannot load image \"%s\"\nSTB Reason: %s\n", filename, stbi_failure_reason());
exit(0);
fprintf(stderr, "It seems that something is wrong about the image you are loading,you will get a image in size 0*0,you can use this to skip the bad image or do something else!");
image i;
return i;
}
if(channels) c = channels;
int i,j,k;