maikonadams / opencl-book-samples

Automatically exported from code.google.com/p/opencl-book-samples
0 stars 0 forks source link

Defect: Missing release in sample code (ch.2, pg. 51) #5

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The sample code for chapter 2 contains a potential memory leak in function 
CreateCommandQueue().

The function returns without releasing an internally allocated buffer, in case 
an error occured while attempting to get context information.

Following is the code in question:

// Allocate memory for the devices buffer
devices = new cl_device_id[deviceBufferSize / sizeof(cl_device_id)];
errNum = clGetContextInfo(context, CL_CONTEXT_DEVICES, 
deviceBufferSize, devices, NULL);
if (errNum != CL_SUCCESS)
{
  cerr << "Failed to get device IDs";
  return NULL;
}

Original issue reported on code.google.com by wel...@gmail.com on 4 Aug 2011 at 12:36

GoogleCodeExporter commented 8 years ago
I have fixed this error in the source code for Chapter_2/HelloWorld (and also 
Chapter_6/HelloBinaryWorld which had the same problem).  The error does still 
remain in the text so I will leave this as accepted Errata.

Original comment by dginsb...@upsamplesoftware.com on 6 Aug 2011 at 12:45