Subject: | 'pointer being freed was not allocated' error on Mac OS X |
At line 598 of Interface.xs, freeifaddrs(ifap) is called. If ifap is
pointing to the first node in the list created by getifaddrs, or ifap is
NULL, then this is fine. However, ifap may be pointing to one of the
other nodes in the list: e.g., when the loop is iterated through once,
and then the strncmp and family check succeed such that the break on
line 593 is executed. In that case, freeifaddrs will fail with a message
like so:
perl(1641) malloc: *** error for object 0x1008b0ce0: pointer being
freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Attached patch simply stores the original pointer value in ifap_begin,
and calls freeifaddrs on that value instead.
IO::Interface 1.06
Perl v5.12.3 built for darwin-multi-2level
Cheers
-Tom
Subject: | ptr-problem.patch |
diff -r IO-Interface-1.06/Interface.xs IO-Interface-1.06.new/Interface.xs
569c569,570
< struct ifaddrs* ifap = NULL;
---
> struct ifaddrs* ifap_begin = NULL;
> struct ifaddrs* ifap = NULL;
583a585
> ifap_begin = ifap;
598c600
< freeifaddrs(ifap);
---
> freeifaddrs(ifap_begin);