This alloca use is inside a lexical block and is used to replace one
element of argv. Use a function local variable, xmalloc and free to
make memory usage pattern more clear.
* src/ar.c (main): Move newp char pointer declaration up.
Use xmalloc to allocate space. free at end of main.
Signed-off-by: Mark Wielaard <mark@klomp.org>
#include <system.h>
#include <printversion.h>
+#include "libeu.h"
#include "arlib.h"
/* For historical reasons the options in the first parameter need
not be preceded by a dash. Add it now if necessary. */
+ char *newp = NULL;
if (argc > 1 && argv[1][0] != '-')
{
size_t len = strlen (argv[1]) + 1;
- char *newp = alloca (len + 1);
+ newp = (char *) xmalloc (len + 1);
newp[0] = '-';
memcpy (&newp[1], argv[1], len);
argv[1] = newp;
break;
}
+ free (newp);
+
return status;
}