diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-06 16:02:43 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-09-06 16:02:43 +0000 |
commit | 6449f0917a8bd6f3182a1d5cada13b50843f6a48 (patch) | |
tree | eead1a5a89b3b4e1aa6e6c983fc046d81a8fd1c1 | |
parent | 5f757f79e427dc32519ca2ae12cfd79a0443deeb (diff) |
[MiBench] consumer-typeset: z31: GetMemory(): don't apply offset to nullptr, it's UB
Caught by D67122
/repositories/llvm-test-suite/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c:352:8: runtime error: applying non-zero offset 96 to null pointer
#0 0x2e682c in GetMemory (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x2e682c)
#1 0x258c4b in InitFiles (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x258c4b)
#2 0x24d34e in main (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x24d34e)
#3 0x7fe3fb2ac09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
#4 0x22e029 in _start (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x22e029)
After that if() the code expects to have enough memory,
so the branch should be unconditionally taken if next_free == nullptr,
git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@371219 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c b/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c index d6e7f1e4..9f968fc7 100644 --- a/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c +++ b/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c @@ -349,7 +349,7 @@ OBJECT GetMemory(int siz, FILE_POS *pos) debug1(DMA, DDD, "GetMemory( %d )", siz); /* get memory from operating system, if not enough left here */ - if( &next_free[siz] > top_free ) + if( !next_free || &next_free[siz] > top_free ) { #if DEBUG_ON DebugRegisterUsage(MEM_OBJECTS, 1, MEM_CHUNK * sizeof(ALIGN)); |