The previous assumption of RzILMem was that the buffer is not owned by it. This made sense, because in the beginning it only held an RzIO buffer. But the Xtensa and Sparc RzAnalysisILInitCallback definition initializes an additional RzILMem object. This additional RzILMem has a sparse buffer in both cases. The Xtensa and Sparc plugin pass the sparse buffer to RzILMem with the assumption that it takes ownership. They have to, because there is no fini() version of RzAnalysisILInitCallback in which they could free the buffer. There are also no API functions to free the buffer in RzILMem. So the plugins don't have a nice way to clean it up in a theoretical fini() callback. This commit fixes the leak by splitting rz_il_mem_new() into two version. One to taking the ownership of the buffer, one borrowing it. This seems the most natural solution, because buffers can abstract from all kind of backends (RzIO, a file, some memory etc.). Each time the ownership of the buffer is different. So the creator of rz_il_mem_new_*() can decide what buffer with what ownership they pass. |
||
|---|---|---|
| .. | ||
| bool.c | ||
| float.c | ||
| label.c | ||
| mem.c | ||
| value.c | ||
| variable.c | ||