mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Fix CID 1393662 (Resource leak)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
fcff2f2ce2
commit
53596f7837
@ -1008,7 +1008,7 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
|
||||
//PERF_COUNT_START("CompileKernelFile")
|
||||
cl_int clStatus = 0;
|
||||
size_t length;
|
||||
char *buildLog = nullptr, *binary;
|
||||
char *buildLog = nullptr;
|
||||
const char *source;
|
||||
size_t source_size[1];
|
||||
int b_error, binary_status, binaryExisted, idx;
|
||||
@ -1051,15 +1051,10 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
|
||||
return 0;
|
||||
}
|
||||
|
||||
binary = (char*) malloc( length + 2 );
|
||||
if ( !binary )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset( binary, 0, length + 2 );
|
||||
b_error |= fread( binary, 1, length, fd ) != length;
|
||||
std::vector<uint8_t> binary(length + 2);
|
||||
|
||||
memset(&binary[0], 0, length + 2);
|
||||
b_error |= fread(&binary[0], 1, length, fd) != length;
|
||||
|
||||
fclose( fd );
|
||||
//PERF_COUNT_SUB("read file")
|
||||
@ -1071,12 +1066,12 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
|
||||
CHECK_OPENCL( clStatus, "clGetContextInfo" );
|
||||
//PERF_COUNT_SUB("get devices")
|
||||
//fprintf(stderr, "[OD] Create kernel from binary\n");
|
||||
const uint8_t *c_binary = &binary[0];
|
||||
gpuInfo->mpArryPrograms[idx] = clCreateProgramWithBinary( gpuInfo->mpContext,numDevices,
|
||||
mpArryDevsID, &length, (const unsigned char**) &binary,
|
||||
mpArryDevsID, &length, &c_binary,
|
||||
&binary_status, &clStatus );
|
||||
CHECK_OPENCL( clStatus, "clCreateProgramWithBinary" );
|
||||
//PERF_COUNT_SUB("clCreateProgramWithBinary")
|
||||
free( binary );
|
||||
free( mpArryDevsID );
|
||||
mpArryDevsID = nullptr;
|
||||
// PERF_COUNT_SUB("binaryExisted")
|
||||
|
Loading…
Reference in New Issue
Block a user