Correct support for adding empty text/byte strings
diff --git a/src/UsefulBuf.c b/src/UsefulBuf.c
index f5149a5..8910794 100644
--- a/src/UsefulBuf.c
+++ b/src/UsefulBuf.c
@@ -268,7 +268,9 @@
uint8_t *pInsertionPoint = ((uint8_t *)pMe->UB.ptr) + uInsertionPos; // PtrMath #5
if(pMe->UB.ptr) {
// To know memmove won't go off end of destination, see PtrMath #6
- memmove(pInsertionPoint, NewData.ptr, NewData.len);
+ if(NewData.ptr != NULL) {
+ memmove(pInsertionPoint, NewData.ptr, NewData.len);
+ }
}
pMe->data_len += NewData.len;
}