If generating a bin file (second half of conditional), make sure the file is closed
authorAndy Maloney <asmaloney@gmail.com>
Mon, 11 Feb 2013 02:55:20 +0000 (21:55 -0500)
committerAndy Maloney <asmaloney@gmail.com>
Mon, 11 Feb 2013 02:55:20 +0000 (21:55 -0500)
(Also fix spelling in comment)

modules/ocl/src/initialization.cpp

index d2dad4a..643626b 100644 (file)
@@ -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);