vector stb: free the memory properly in the exception cases. 61/215661/1 accepted/tizen_5.5_unified_mobile_hotfix tizen_5.5_mobile_hotfix accepted/tizen/5.5/unified/20191031.015024 accepted/tizen/5.5/unified/mobile/hotfix/20201027.075200 accepted/tizen/unified/20191014.062459 submit/tizen/20191014.053053 submit/tizen/20191014.060638 submit/tizen_5.5/20191031.000005 submit/tizen_5.5_mobile_hotfix/20201026.185105 tizen_5.5.m2_release
authorHermet Park <hermetpark@gmail.com>
Mon, 14 Oct 2019 05:14:16 +0000 (14:14 +0900)
committerHermet Park <hermetpark@gmail.com>
Mon, 14 Oct 2019 05:15:44 +0000 (14:15 +0900)
Change-Id: Ib2699f068217f20f565a2045f7e0fc53f32a8f95

src/vector/stb/stb_image.h

index aa58412..8c039ef 100644 (file)
@@ -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;
 }