On Tue, Jun 21, 2011 at 8:17 AM, Russell Bryant
<russell(a)russellbryant.net> wrote:
On Sat, Jun 4, 2011 at 7:54 AM, Jaroslav Škarvada
<jskarvad(a)redhat.com> wrote:
> - _instance.setProperty("hostname", mh_hostname());
> - _instance.setProperty("uuid", mh_uuid());
> + _instance.setProperty("hostname", str = (char *)mh_hostname());
> + free(str);
> + _instance.setProperty("uuid", str = (char *)mh_uuid());
> + free(str);
These changes will cause a crash. These functions don't leak memory.
They do return dynamically allocated memory, but the memory is only
allocated a single time and then is saved off to a static pointer.
Future invokations of the function return the saved off buffer.
To clarify, what I quoted was just an example. I believe this applies
to all of the changes.
--
Russell Bryant