From 5f299d76a0d8f5374b8018faa65465632c45d13e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 17 Jul 2015 21:09:42 -0400 Subject: [PATCH] Cleared UBsan error on non-null pointers being used with memcpy and memmove from library functions memcpy_s and memmove_s --- misc.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/misc.h b/misc.h index 6b6ed2a5..ed3ae048 100644 --- a/misc.h +++ b/misc.h @@ -174,14 +174,22 @@ inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t cou { if (count > sizeInBytes) throw InvalidArgument("memcpy_s: buffer overflow"); - memcpy(dest, src, count); + + // TODO: fix callers. Its easier than it sounds because of the way + // Put and Put2 are used in filters. + if(dest && src && count) + memcpy(dest, src, count); } inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t count) { if (count > sizeInBytes) throw InvalidArgument("memmove_s: buffer overflow"); - memmove(dest, src, count); + + // TODO: fix callers. Its easier than it sounds because of the way + // Put and Put2 are used in filters. + if(dest && src && count) + memmove(dest, src, count); } #if __BORLANDC__ >= 0x620