warn instead of assert on case where MemPatch application would exceed size of target buffer (which should never happen, if you're applying the patch to the same type it was generated from)

This commit is contained in:
Adam Lederer 2024-08-18 20:00:11 -07:00 committed by tildearrow
parent 94ef697ea6
commit ea02a913b2

View file

@ -17,7 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <cassert>
#include "dataErrors.h"
#include "engine.h"
#include "instrument.h"
@ -400,7 +399,11 @@ bool MemPatch::calcDiff(const void* pre, const void* post, size_t inputSize) {
void MemPatch::applyAndReverse(void* target, size_t targetSize) {
if (size==0) return;
assert(offset+size<=targetSize);
if (offset+size>targetSize) {
logW("MemPatch (offset %d, size %d) exceeds target size (%d), can't apply!",offset,size,targetSize);
return;
}
unsigned char* targetBytes=(unsigned char*)target;
// swap this->data and its segment on target