From: Hermet Park Date: Mon, 14 Oct 2019 05:14:16 +0000 (+0900) Subject: vector stb: free the memory properly in the exception cases. X-Git-Tag: submit/tizen/20191014.053053^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91ba796c0f15dfc1a8e11f58ecbfe5a86b706f80;p=platform%2Fcore%2Fuifw%2Flottie-player.git vector stb: free the memory properly in the exception cases. Change-Id: Ib2699f068217f20f565a2045f7e0fc53f32a8f95 --- diff --git a/src/vector/stb/stb_image.h b/src/vector/stb/stb_image.h index aa58412..8c039ef 100644 --- a/src/vector/stb/stb_image.h +++ b/src/vector/stb/stb_image.h @@ -1178,8 +1178,10 @@ STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer - if (fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR) == -1) + if (fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR) == -1) { + stbi_image_free(result); return stbi__errpuc("fseek() error", "File Seek Fail"); + } } return result; } @@ -1192,8 +1194,10 @@ STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); if (result) { // need to 'unget' all the characters in the IO buffer - if (fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR) == -1) + if (fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR) == -1) { + stbi_image_free(result); return (stbi__uint16 *) stbi__errpuc("fseek() error", "File Seek Fail"); + } } return result; }