From 21bfddf2afe2cf99f21a41f835299988ba9a8621 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 20 Sep 2019 12:30:44 +0100 Subject: [PATCH] Don't crash on reading an unexpected amount of padding * The connection is likely lost/corrupted, but we shouldn't crash --- renderdoc/core/replay_proxy.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 7fbe9258f..749f8f27e 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -1813,8 +1813,6 @@ void DoSerialise(SerialiserType &ser, DeltaSection &el) template void ReplayProxy::DeltaTransferBytes(SerialiserType &xferser, bytebuf &referenceData, bytebuf &newData) { - char empty[128] = {}; - // we use a list so that we don't have to reserve and pushing new sections will never cause // previous ones to be reallocated and move around lots of data. std::list deltas; @@ -1844,10 +1842,13 @@ void ReplayProxy::DeltaTransferBytes(SerialiserType &xferser, bytebuf &reference // add any necessary padding. uint64_t offs = ser.GetReader()->GetOffset(); RDCASSERT(offs <= uncompSize, offs, uncompSize); - RDCASSERT(uncompSize - offs < sizeof(empty), offs, uncompSize); if(offs < uncompSize) - ser.GetReader()->Read(empty, uncompSize - offs); + { + if(uncompSize - offs > 128) + RDCERR("Unexpected amount of padding: %llu", uncompSize - offs); + ser.GetReader()->Read(NULL, uncompSize - offs); + } } if(deltas.empty()) @@ -2028,6 +2029,8 @@ void ReplayProxy::DeltaTransferBytes(SerialiserType &xferser, bytebuf &reference SERIALISE_ELEMENT(deltas); + char empty[128] = {}; + // add any necessary padding. uint64_t offs = ser.GetWriter()->GetOffset(); RDCASSERT(offs <= uncompSize, offs, uncompSize);