summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2013-08-08 08:19:01 +0200
committerNorbert Thiebaud <nthiebaud@gmail.com>2013-08-08 20:05:59 +0000
commit5fbc94bc00d04c3af9e519699f91c0fff32df0c3 (patch)
tree7eefe263bd46b5d7088c4190b568a28652fb30d1 /sc/source
parent5f23dac65b39750356418d7d8f490a37a944c34c (diff)
Fix some memory leaks
Change-Id: If8c1b341b8493b8902f060d8d13bbb7d08991cd9 Reviewed-on: https://gerrit.libreoffice.org/5309 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/opencl/openclwrapper.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/sc/source/core/opencl/openclwrapper.cxx b/sc/source/core/opencl/openclwrapper.cxx
index bc9721750cc6..055771704c37 100644
--- a/sc/source/core/opencl/openclwrapper.cxx
+++ b/sc/source/core/opencl/openclwrapper.cxx
@@ -307,6 +307,12 @@ int OpenclDevice::GeneratBinFromKernelSource( cl_program program, const char * c
binaries[i] = (char*) malloc( sizeof(char) * binarySizes[i] );
if ( binaries[i] == NULL )
{
+ for ( unsigned int j = 0; j < i ; j++)
+ {
+ if (binaries[j])
+ free(binaries[j]);
+ }
+ free(binaries);
return 0;
}
}
@@ -513,12 +519,14 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
b_error |= fseek( fd, 0, SEEK_SET ) < 0;
if ( b_error )
{
+ free(mpArryDevsID);
return 0;
}
binary = (char*) malloc( length + 2 );
if ( !binary )
{
+ free(mpArryDevsID);
return 0;
}
@@ -531,7 +539,12 @@ int OpenclDevice::CompileKernelFile( GPUEnv *gpuInfo, const char *buildOption )
// grab the handles to all of the devices in the context.
clStatus = clGetContextInfo( gpuInfo->mpContext, CL_CONTEXT_DEVICES,
sizeof( cl_device_id ) * numDevices, mpArryDevsID, NULL );
- CHECK_OPENCL( clStatus, "clGetContextInfo" );
+ if (clStatus != CL_SUCCESS)
+ {
+ fprintf (stderr, "OpenCL error code is %d at " SAL_DETAIL_WHERE " when clGetContextInfo .\n", clStatus);
+ free(binary);
+ return 0;
+ }
fprintf(stderr, "Create kernel from binary\n");
gpuInfo->mpArryPrograms[idx] = clCreateProgramWithBinary( gpuInfo->mpContext,numDevices,