History

avdevice/decklink: fix leak when listing devices and there is no memory

Fixes Coverity CID 1419523.

Marton Balint committed 8 years ago

Commit 87455b71 parent 5f6126e1 file · +5 −12Browse files

Unified · Split

libavdevice/decklink_common.cpp+5−12
@@ -322,21 +322,14 @@ int ff_decklink_list_devices(AVFormatContext *avctx, · 321 unmodified lines
322322 ret = AVERROR(ENOMEM);
323323 goto next;
324324 }
325− new_device->device_name = av_strdup(displayName);
326− if (!new_device->device_name) {
327− ret = AVERROR(ENOMEM);
328− goto next;
329− }
330325
326+ new_device->device_name = av_strdup(displayName);
331327 new_device->device_description = av_strdup(displayName);
332− if (!new_device->device_description) {
333− av_freep(&new_device->device_name);
334− ret = AVERROR(ENOMEM);
335− goto next;
336− }
337328
338− if ((ret = av_dynarray_add_nofree(&device_list->devices,
339− &device_list->nb_devices, new_device)) < 0) {
329+ if (!new_device->device_name ||
330+ !new_device->device_description ||
331+ av_dynarray_add_nofree(&device_list->devices, &device_list->nb_devices, new_device) < 0) {
332+ ret = AVERROR(ENOMEM);
340333 av_freep(&new_device->device_name);
341334 av_freep(&new_device->device_description);
342335 av_freep(&new_device);

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