From 2075236757f1b8fefeb7f956a145e257c382de30 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Sun, 10 Feb 2013 21:55:20 -0500 Subject: [PATCH] If generating a bin file (second half of conditional), make sure the file is closed (Also fix spelling in comment) --- modules/ocl/src/initialization.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/ocl/src/initialization.cpp b/modules/ocl/src/initialization.cpp index d2dad4a84..643626bce 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);