From: Andy Maloney Date: Mon, 11 Feb 2013 02:55:20 +0000 (-0500) Subject: If generating a bin file (second half of conditional), make sure the file is closed X-Git-Tag: accepted/tizen/6.0/unified/20201030.111113~1314^2~1531^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2075236757f1b8fefeb7f956a145e257c382de30;p=platform%2Fupstream%2Fopencv.git If generating a bin file (second half of conditional), make sure the file is closed (Also fix spelling in comment) --- diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp index d2dad4a..643626b 100644 --- a/modules/ocl/src/initialization.cpp +++ b/modules/ocl/src/initialization.cpp @@ -538,10 +538,12 @@ namespace cv filename = clCxt->impl->Binpath + kernelName + "_" + clCxt->impl->devName + ".clb"; } - FILE *fp; - fp = fopen(filename.c_str(), "rb"); - if(fp == NULL || clCxt->impl->Binpath.size() == 0) //we should genetate a binary file for the first time. + FILE *fp = fopen(filename.c_str(), "rb"); + if(fp == NULL || clCxt->impl->Binpath.size() == 0) //we should generate a binary file for the first time. { + if(fp != NULL) + fclose(fp); + program = clCreateProgramWithSource( clCxt->impl->clContext, 1, source, NULL, &status); openCLVerifyCall(status);