gemini-code-assist[bot] commented on code in PR #419:
URL: https://github.com/apache/tvm-ffi/pull/419#discussion_r2709741246
##########
include/tvm/ffi/string.h:
##########
@@ -754,7 +754,9 @@ class String {
}
void InitData(const char* data, size_t size) {
char* dest_data = InitSpaceForSize(size);
- std::memcpy(dest_data, data, size);
+ if (size > 0) {
+ std::memcpy(dest_data, data, size);
+ }
Review Comment:

This is a great fix to prevent undefined behavior when `memcpy` is called
with a size of 0 and a null source pointer. I noticed that the
`Bytes::InitData` method in this same file has a similar implementation without
this check. It would be beneficial to apply the same fix there to ensure
consistency and prevent the same undefined behavior in the `Bytes` class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]