Fix various null pointer issues detected by Coverity

This commit is contained in:
Richard Stanway 2017-02-25 16:45:45 +01:00
parent 6dd1707752
commit 8b640fae24
No known key found for this signature in database
GPG Key ID: AAC1E5265D71B3FD
10 changed files with 30 additions and 39 deletions

View File

@ -178,7 +178,7 @@ void ff_decoder_refresh(void *opaque)
struct ff_frame *frame;
if (decoder && decoder->stream) {
if (decoder->stream) {
if (decoder->frame_queue.size == 0) {
if (!decoder->eof || !decoder->finished) {
// We expected a frame, but there were none

View File

@ -455,7 +455,7 @@ void device_load_texture(gs_device_t *device, gs_texture_t *tex, int unit)
/* need a pixel shader to properly bind textures */
if (!device->cur_pixel_shader)
tex = NULL;
goto fail;
if (cur_tex == tex)
return;

View File

@ -31,7 +31,7 @@ struct decl_param {
static inline void decl_param_free(struct decl_param *param)
{
if (param)
if (param->name)
bfree(param->name);
memset(param, 0, sizeof(struct decl_param));
}

View File

@ -149,7 +149,7 @@ static inline void render_display_begin(struct obs_display *display,
{
struct vec4 clear_color;
gs_load_swapchain(display ? display->swap : NULL);
gs_load_swapchain(display->swap);
if (size_changed)
gs_resize(cx, cy);

View File

@ -551,7 +551,7 @@ static inline struct list_data *get_list_fmt_data(struct obs_property *p,
enum obs_combo_format format)
{
struct list_data *data = get_list_data(p);
return (data->format == format) ? data : NULL;
return (data && data->format == format) ? data : NULL;
}
/* ------------------------------------------------------------------------- */

View File

@ -1395,8 +1395,7 @@ void obs_sceneitem_remove(obs_sceneitem_t *item)
scene = item->parent;
if (scene)
full_lock(scene);
full_lock(scene);
if (item->removed) {
if (scene)

View File

@ -1884,10 +1884,9 @@ void obs_source_filter_add(obs_source_t *source, obs_source_t *filter)
signal_handler_signal(source->context.signals, "filter_add", &cd);
if (source && filter)
blog(LOG_DEBUG, "- filter '%s' (%s) added to source '%s'",
filter->context.name, filter->info.id,
source->context.name);
blog(LOG_DEBUG, "- filter '%s' (%s) added to source '%s'",
filter->context.name, filter->info.id,
source->context.name);
}
static bool obs_source_filter_remove_refless(obs_source_t *source,
@ -1920,10 +1919,9 @@ static bool obs_source_filter_remove_refless(obs_source_t *source,
signal_handler_signal(source->context.signals, "filter_remove", &cd);
if (source && filter)
blog(LOG_DEBUG, "- filter '%s' (%s) removed from source '%s'",
filter->context.name, filter->info.id,
source->context.name);
blog(LOG_DEBUG, "- filter '%s' (%s) removed from source '%s'",
filter->context.name, filter->info.id,
source->context.name);
if (filter->info.filter_remove)
filter->info.filter_remove(filter->context.data,

View File

@ -927,11 +927,6 @@ int obs_reset_video(struct obs_video_info *ovi)
stop_video();
obs_free_video();
if (!ovi) {
obs_free_graphics();
return OBS_VIDEO_SUCCESS;
}
/* align to multiple-of-two and SSE alignment sizes */
ovi->output_width &= 0xFFFFFFFC;
ovi->output_height &= 0xFFFFFFFE;

View File

@ -73,11 +73,12 @@ static void flv_output_stop(void *data, uint64_t ts)
struct flv_output *stream = data;
if (stream->active) {
if (stream->file)
if (stream->file) {
write_file_info(stream->file, stream->last_packet_ts,
os_ftelli64(stream->file));
fclose(stream->file);
fclose(stream->file);
}
obs_output_end_data_capture(stream->output);
stream->active = false;
stream->sent_headers = false;

View File

@ -95,25 +95,23 @@ static void rtmp_stream_destroy(void *data)
if (stream->socket_thread_active)
pthread_join(stream->socket_thread, NULL);
if (stream) {
free_packets(stream);
dstr_free(&stream->path);
dstr_free(&stream->key);
dstr_free(&stream->username);
dstr_free(&stream->password);
dstr_free(&stream->encoder_name);
dstr_free(&stream->bind_ip);
os_event_destroy(stream->stop_event);
os_sem_destroy(stream->send_sem);
pthread_mutex_destroy(&stream->packets_mutex);
circlebuf_free(&stream->packets);
free_packets(stream);
dstr_free(&stream->path);
dstr_free(&stream->key);
dstr_free(&stream->username);
dstr_free(&stream->password);
dstr_free(&stream->encoder_name);
dstr_free(&stream->bind_ip);
os_event_destroy(stream->stop_event);
os_sem_destroy(stream->send_sem);
pthread_mutex_destroy(&stream->packets_mutex);
circlebuf_free(&stream->packets);
#ifdef TEST_FRAMEDROPS
circlebuf_free(&stream->droptest_info);
circlebuf_free(&stream->droptest_info);
#endif
if (stream->write_buf)
bfree(stream->write_buf);
bfree(stream);
}
if (stream->write_buf)
bfree(stream->write_buf);
bfree(stream);
}
static void *rtmp_stream_create(obs_data_t *settings, obs_output_t *output)