From d93c204f3769c2cb33439c2c41b2d5d4a7de9c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 24 Jan 2014 13:26:20 +0000 Subject: [PATCH] coverity#1158180 Argument cannot be negative Change-Id: Ic8dd6aeff02b08c8a3951ce0378eab95ba0c6f1d --- sc/source/core/opencl/opencl_device_selection.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sc/source/core/opencl/opencl_device_selection.h b/sc/source/core/opencl/opencl_device_selection.h index 85ee9f683fd5..2712adcf288d 100644 --- a/sc/source/core/opencl/opencl_device_selection.h +++ b/sc/source/core/opencl/opencl_device_selection.h @@ -347,6 +347,7 @@ inline ds_status readProFile(const char* fileName, char** content, size_t* conte FILE* input = NULL; size_t size = 0; char* binary = NULL; + long pos = -1; *contentSize = 0; *content = NULL; @@ -358,7 +359,14 @@ inline ds_status readProFile(const char* fileName, char** content, size_t* conte } fseek(input, 0L, SEEK_END); - size = ftell(input); + pos = ftell(input); + if (pos < 0) + { + fclose(input); + return DS_FILE_ERROR; + } + + size = pos; rewind(input); binary = (char*)malloc(size); if (binary == NULL)