}
unsigned l_numLinks = countLinks(l_socket, l_linkResults) + countLinks(l_socket, l_addrResults);
- struct ifaddrs *l_links[l_numLinks];
+ struct ifaddrs **l_links;
+ l_links = malloc(l_numLinks * sizeof(struct ifaddrs *));
+ if (!l_links)
+ {
+ close(l_socket);
+ freeResultList(l_linkResults);
+ return -1;
+ }
+
memset(l_links, 0, l_numLinks * sizeof(struct ifaddrs *));
interpret(l_socket, l_linkResults, l_links, ifap);
freeResultList(l_linkResults);
freeResultList(l_addrResults);
+ free(l_links);
close(l_socket);
return 0;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <alloca.h>
#include <stdio.h>
#include <string.h>
#include <mntent.h>
/* Extend the mode parameter with "c" to disable cancellation in the
I/O functions and "e" to set FD_CLOEXEC. */
size_t modelen = strlen (mode);
- char newmode[modelen + 3];
+ char *newmode;
+
+ newmode = alloca(modelen + 3);
+
memcpy (newmode, mode, modelen);
memcpy (newmode + modelen, "ce", 3);
FILE *result = fopen (file, newmode);