opencl-book-samples icon indicating copy to clipboard operation
opencl-book-samples copied to clipboard

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

Open GoogleCodeExporter opened this issue 9 years ago • 1 comments

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 [email protected] on 4 Aug 2011 at 12:36

GoogleCodeExporter avatar Mar 14 '15 09:03 GoogleCodeExporter

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 [email protected] on 6 Aug 2011 at 12:45

  • Changed state: Accepted

GoogleCodeExporter avatar Mar 14 '15 09:03 GoogleCodeExporter