From adb65f53b89820ecebdd8b0437715c548995c3d7 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 25 Feb 2019 08:12:27 -0500 Subject: [PATCH] fix possible null pointer reference fixes #709 Change-Id: I65f9ad85547f12b12202dd0f76b34b00525b96ca --- recording-daemon/db.c | 5 +++-- recording-daemon/tag.c | 2 +- recording-daemon/tag.h | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/recording-daemon/db.c b/recording-daemon/db.c index 7b183c4ba..444b32cdc 100644 --- a/recording-daemon/db.c +++ b/recording-daemon/db.c @@ -6,6 +6,7 @@ #include "types.h" #include "main.h" #include "log.h" +#include "tag.h" static MYSQL __thread *mysql_conn; @@ -286,8 +287,8 @@ void db_do_stream(metafile_t *mf, output_t *op, const char *type, stream_t *stre .buffer_length = sizeof(ssrc), .is_unsigned = 1, }; - if (stream && mf->tags->len > stream->tag) { - tag_t *tag = g_ptr_array_index(mf->tags, stream->tag); + if (stream) { + tag_t *tag = tag_get(mf, stream->tag); my_cstr(&b[9], tag->label ? : ""); } else diff --git a/recording-daemon/tag.c b/recording-daemon/tag.c index 1f4bf7437..c7664d97c 100644 --- a/recording-daemon/tag.c +++ b/recording-daemon/tag.c @@ -2,7 +2,7 @@ // XXX copied from stream.c - unify? -static tag_t *tag_get(metafile_t *mf, unsigned long id) { +tag_t *tag_get(metafile_t *mf, unsigned long id) { if (mf->tags->len <= id) g_ptr_array_set_size(mf->tags, id + 1); tag_t *ret = g_ptr_array_index(mf->tags, id); diff --git a/recording-daemon/tag.h b/recording-daemon/tag.h index c55528aa6..ffec554cf 100644 --- a/recording-daemon/tag.h +++ b/recording-daemon/tag.h @@ -3,6 +3,7 @@ #include "types.h" +tag_t *tag_get(metafile_t *mf, unsigned long id); void tag_name(metafile_t *mf, unsigned long t, const char *); void tag_label(metafile_t *mf, unsigned long t, const char *); void tag_free(tag_t *);