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.
This commit is contained in:
Markus Makela 2016-02-12 16:18:24 +02:00
parent 74c8b5e296
commit 36896afcbd

View File

@ -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
{