use alloca instead of malloc for command buffer allocation
This commit is contained in:
parent
1efb6b75f4
commit
7d3e2eebb2
16
src/psl2c.c
16
src/psl2c.c
|
@ -365,7 +365,8 @@ int main(int argc, const char **argv)
|
||||||
if ((fpout = fopen(argv[2], "w"))) {
|
if ((fpout = fopen(argv[2], "w"))) {
|
||||||
FILE *pp;
|
FILE *pp;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *cmd, checksum[64] = "";
|
size_t cmdsize = 16 + strlen(argv[1]);
|
||||||
|
char *cmd = alloca(cmdsize), checksum[64] = "";
|
||||||
|
|
||||||
_add_punycode_if_needed(psl->suffixes);
|
_add_punycode_if_needed(psl->suffixes);
|
||||||
_add_punycode_if_needed(psl->suffix_exceptions);
|
_add_punycode_if_needed(psl->suffix_exceptions);
|
||||||
|
@ -373,14 +374,11 @@ int main(int argc, const char **argv)
|
||||||
_print_psl_entries(fpout, psl->suffixes, "suffixes");
|
_print_psl_entries(fpout, psl->suffixes, "suffixes");
|
||||||
_print_psl_entries(fpout, psl->suffix_exceptions, "suffix_exceptions");
|
_print_psl_entries(fpout, psl->suffix_exceptions, "suffix_exceptions");
|
||||||
|
|
||||||
if ((cmd = malloc(16 + strlen(argv[1])))) {
|
snprintf(cmd, cmdsize, "sha1sum %s", argv[1]);
|
||||||
snprintf(cmd, 16 + strlen(argv[1]), "sha1sum %s", argv[1]);
|
if ((pp = popen(cmd, "r"))) {
|
||||||
if ((pp = popen(cmd, "r"))) {
|
if (fscanf(pp, "%63[0-9a-zA-Z]", checksum) < 1)
|
||||||
if (fscanf(pp, "%63[0-9a-zA-Z]", checksum) < 1)
|
*checksum = 0;
|
||||||
*checksum = 0;
|
pclose(pp);
|
||||||
pclose(pp);
|
|
||||||
}
|
|
||||||
free(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat(argv[1], &st) != 0)
|
if (stat(argv[1], &st) != 0)
|
||||||
|
|
Loading…
Reference in New Issue