if I allocate some memory using malloc() , there is a way to mark it read-only. So memcpy () fails if someone tries to write to it?
This is due to the faulty api architecture, where users skip the const pointer returned by the GetValue() method, which is part of a large memory structure. Since we want to avoid copying a large piece of memory, we return a live pointer inside structured memory, which has a specific format. Now the problem is that some users find a hack to get things that work directly when writing to this memory and avoid calling SetValue (), which distributes and correctly transfers the binary memory format that we developed. Despite the fact that it once worked, but sometimes it causes a violation of memory access due to incorrect interpretation of control flags that were canceled by the user.
Educating the user is one of the tasks, but let me say that now we want the code to crash there.
I'm just wondering if we can just protect against this case.
For an analogy, suppose someone gets a blob column from a sqlite statement and then writes back. Although in the case of sqlite this will not make sense, but this is a bit of a hassle in our case.
c ++ c memory-management malloc heap-corruption
particle Feb 18 '13 at 7:39 2013-02-18 07:39
source share