commit 99c8f84efc280265d026737b2bdfd4741c8a74e8
parent 4e81cc2f8a28ba168b446dbbd24a3877e6837da9
Author: Quentin Carbonneaux <quentin@c9x.me>
Date: Tue, 2 Mar 2021 10:01:26 +0100
fix a couple asan complaints
Diffstat:
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/spill.c b/spill.c
@@ -173,11 +173,13 @@ limit(BSet *b, int k, BSet *f)
bsclr(b, t);
tarr[i++] = t;
}
- if (!f)
- qsort(tarr, nt, sizeof tarr[0], tcmp0);
- else {
- fst = f;
- qsort(tarr, nt, sizeof tarr[0], tcmp1);
+ if (nt > 1) {
+ if (!f)
+ qsort(tarr, nt, sizeof tarr[0], tcmp0);
+ else {
+ fst = f;
+ qsort(tarr, nt, sizeof tarr[0], tcmp1);
+ }
}
for (i=0; i<k && i<nt; i++)
bsset(b, tarr[i]);
diff --git a/util.c b/util.c
@@ -246,13 +246,15 @@ void
idup(Ins **pd, Ins *s, ulong n)
{
*pd = alloc(n * sizeof(Ins));
- memcpy(*pd, s, n * sizeof(Ins));
+ if (n)
+ memcpy(*pd, s, n * sizeof(Ins));
}
Ins *
icpy(Ins *d, Ins *s, ulong n)
{
- memcpy(d, s, n * sizeof(Ins));
+ if (n)
+ memcpy(d, s, n * sizeof(Ins));
return d + n;
}