History

cmdutils_opencl: fix resource_leak cid 1396852

CID: 1396852 check the devices_list alloc status, and release the devices_list when alloc devices error

Steven Liu committed 9 years ago

Commit aa798251 parent 08fdf961 file · +7 −2Browse files

Showing the changes to cmdutils_opencl.c (1 of 1 file). Show all

Unified · Split

cmdutils_opencl.c+7−2
@@ -213,22 +213,27 @@ static int compare_ocl_device_desc(const void *a, const void *b) · 212 unmodified lines
213213
214214 int opt_opencl_bench(void *optctx, const char *opt, const char *arg)
215215 {
216− int i, j, nb_devices = 0, count = 0;
216+ int i, j, nb_devices = 0, count = 0, ret = 0;
217217 int64_t score = 0;
218218 AVOpenCLDeviceList *device_list;
219219 AVOpenCLDeviceNode *device_node = NULL;
220220 OpenCLDeviceBenchmark *devices = NULL;
221221 cl_platform_id platform;
222222
223− av_opencl_get_device_list(&device_list);
223+ ret = av_opencl_get_device_list(&device_list);
224+ if (ret < 0) {
225+ return ret;
226+ }
224227 for (i = 0; i < device_list->platform_num; i++)
225228 nb_devices += device_list->platform_node[i]->device_num;
226229 if (!nb_devices) {
227230 av_log(NULL, AV_LOG_ERROR, "No OpenCL device detected!\n");
231+ av_opencl_free_device_list(&device_list);
228232 return AVERROR(EINVAL);
229233 }
230234 if (!(devices = av_malloc_array(nb_devices, sizeof(OpenCLDeviceBenchmark)))) {
231235 av_log(NULL, AV_LOG_ERROR, "Could not allocate buffer\n");
236+ av_opencl_free_device_list(&device_list);
232237 return AVERROR(ENOMEM);
233238 }
234239

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t