From: Joonbum Ko Date: Thu, 24 Jan 2019 02:40:26 +0000 (+0900) Subject: sample: Added error checking for fseek X-Git-Tag: accepted/tizen/5.0/unified/20190125.054705~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=710c92ef4eab49d2e9683ad491de0eda9a4a8e98;p=platform%2Fcore%2Fuifw%2Fvulkan-wsi-tizen.git sample: Added error checking for fseek Change-Id: I6a4a0068095a1103fa582eeeba5f1ac5e775e251 Signed-off-by: Joonbum Ko --- diff --git a/samples/tri.c b/samples/tri.c index df4734b..b42cd55 100644 --- a/samples/tri.c +++ b/samples/tri.c @@ -1250,14 +1250,21 @@ char *demo_read_spv(const char *filename, size_t *psize) { if (!fp) return NULL; - fseek(fp, 0L, SEEK_END); + if (fseek(fp, 0L, SEEK_END) == -1) { + fclose(fp); + return NULL; + } + size = ftell(fp); if (size < 0) { fclose(fp); return NULL; } - fseek(fp, 0L, SEEK_SET); + if (fseek(fp, 0L, SEEK_SET) == -1) { + fclose(fp); + return NULL; + } shader_code = malloc(size); retVal = fread(shader_code, size, 1, fp);