Fixes Coverity CID 1419523.
Showing the changes to libavdevice/decklink_common.cpp (1 of 1 file). Show all
Unified · Split
| @@ -322,21 +322,14 @@ int ff_decklink_list_devices(AVFormatContext *avctx, · 321 unmodified lines | ||
| 322 | 322 | ret = AVERROR(ENOMEM); |
| 323 | 323 | goto next; |
| 324 | 324 | } |
| 325 | − new_device->device_name = av_strdup(displayName); | |
| 326 | − if (!new_device->device_name) { | |
| 327 | − ret = AVERROR(ENOMEM); | |
| 328 | − goto next; | |
| 329 | − } | |
| 330 | 325 | |
| 326 | + new_device->device_name = av_strdup(displayName); | |
| 331 | 327 | 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 | − } | |
| 337 | 328 | |
| 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); | |
| 340 | 333 | av_freep(&new_device->device_name); |
| 341 | 334 | av_freep(&new_device->device_description); |
| 342 | 335 | av_freep(&new_device); |