Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you call memcpy in a way that calls malloc

uh... How exactly?

memcpy copies memory from one place in memory to another. That's all it does. There is no "calling memcpy in a way that calls malloc".



if dst and src in memcpy overlap, the result is UB. so there's your window of opportunity.

well, you asked...


Haha, you're right, it's technically allowed for memcpy to call malloc in that circumstance.


memcpy wouldn't, but memmove would. memcpy doesn't check for or care about overlaps (and therefore the result is unpredictable - it'll depend on the implementation)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: