Fix uninitialized memory use with -MT and -MQ

This didn't break unless the first uninitialized byte was non-zero,
which happened to be the case on someone's Windows machine.

Would it be worth it setting up Valgrind in CI?
This commit is contained in:
ISSOtm
2020-05-06 19:19:10 +02:00
parent 645473e336
commit b299f6fb3b

View File

@@ -454,7 +454,6 @@ int main(int argc, char *argv[])
/* Long-only options */
case 0:
if (depType) {
switch (depType) {
case 'G':
oGeneratedMissingIncludes = true;
@@ -472,9 +471,16 @@ int main(int argc, char *argv[])
ep = make_escape(ep);
nTargetFileNameLen += strlen(ep) + 1;
if (!tzTargetFileName) {
/* On first alloc, make an empty str */
tzTargetFileName =
malloc(nTargetFileNameLen + 1);
*tzTargetFileName = '\0';
} else {
tzTargetFileName =
realloc(tzTargetFileName,
nTargetFileNameLen + 1);
}
if (tzTargetFileName == NULL)
err(1, "Cannot append new file to target file list");
strcat(tzTargetFileName, ep);
@@ -486,7 +492,6 @@ int main(int argc, char *argv[])
*ptr = '\0';
break;
}
}
break;
/* Unrecognized options */