Open pjmlp opened 4 years ago
Thanks for spotting. This is not really a possible memory corruption error, but it technically is Undefined Behaviour (which could manifest itself as corrupting memory or doing whatever, at runtime), since arrays given by pointer + length must point to valid memory even when length=0 due to some incredible stupidity in the C spec.
I'm not aware of a case where that actually breaks an existing compiler, and I deeply feel that the code is "right" as is, so I'm not making it wrong by adding a conditional just to fix an issue that isn't one.
I should have used my own existing copy_mem() function, though, to simply avoid these stupid kinds of issues, or at least confine these issues to a central place in case efficiency matters (it doesn't).
The code is currently collecting dust while I'm mentally preparing to possibly attempting an improved version of the project, which initially won't even include code generation or ELF handling, but probably include a simple interpreter to allow for quicker design iteration. So I'm not fixing this for the time being.
After going through with clang tidy, there was at least a possible memory corruption error that was found.
Might be a false positive, as everything else was pretty ok.