From 36896afcbda5dff7671fd9888c3635ca3770ddb4 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Fri, 12 Feb 2016 16:18:24 +0200 Subject: [PATCH] Fixed missing NULL check when reading records If the binlog record was not found, a NULL pointer is returned. There was no check for the return value and it assumed that it was always non-NULL. --- server/modules/routing/binlog/blr_master.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/binlog/blr_master.c b/server/modules/routing/binlog/blr_master.c index a3248aaa6..e2fde1d4d 100644 --- a/server/modules/routing/binlog/blr_master.c +++ b/server/modules/routing/binlog/blr_master.c @@ -1354,9 +1354,18 @@ uint32_t partialpos = 0; { /** Read the complete event from the disk */ GWBUF *record = blr_read_events_from_pos(router, old_pos, &hdr, hdr.next_pos); - uint8_t *data = GWBUF_DATA(record); - blr_distribute_binlog_record(router, &hdr, data); - gwbuf_free(record); + if (record) + { + uint8_t *data = GWBUF_DATA(record); + blr_distribute_binlog_record(router, &hdr, data); + gwbuf_free(record); + } + else + { + MXS_ERROR("Failed to read event at position" + "%lu with a size of %u bytes.", + old_pos, hdr.event_size); + } } else {