summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Chen <ddchen@apple.com>2022-04-19 01:38:35 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-19 01:38:35 +0000
commit547ff22cf228aacb05935378b9164e9fc8d4b51f (patch)
treeba9b50c6b9c9b2e6c0230e6ba974d320e0dcc343
parented2a1806484b9c61ffaadb2dee1c6c68c9b8e207 (diff)
parente12860bd159e767a007da7371f69a2dc245b0366 (diff)
downloadscudo-547ff22cf228aacb05935378b9164e9fc8d4b51f.tar.gz
[scudo] Use template specialization on Quarantine to avoid zero-length array am: 6bb3118929 am: 8011665133 am: 101f5c7373 am: e12860bd15
Original change: https://android-review.googlesource.com/c/platform/external/scudo/+/2063219 Change-Id: I3f147ab5f8ac065ac82b4bb5d68fda3c1bf5f4df Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--standalone/secondary.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/standalone/secondary.h b/standalone/secondary.h
index abb58a2882a..0f8fafe0a6b 100644
--- a/standalone/secondary.h
+++ b/standalone/secondary.h
@@ -362,6 +362,18 @@ private:
u64 Time;
};
+ // Template specialization to avoid producing zero-length array
+ template <size_t Size> class QuarantineBlocks {
+ public:
+ CachedBlock &operator[](uptr Idx) { return Blocks[Idx]; }
+ private:
+ CachedBlock Blocks[Size];
+ };
+ template <> class QuarantineBlocks<0> {
+ public:
+ CachedBlock &operator[](uptr UNUSED Idx) { UNREACHABLE("Unsupported!"); }
+ };
+
void releaseIfOlderThan(CachedBlock &Entry, u64 Time) {
if (!Entry.CommitBase || !Entry.Time)
return;
@@ -395,7 +407,7 @@ private:
atomic_s32 ReleaseToOsIntervalMs = {};
CachedBlock Entries[Config::SecondaryCacheEntriesArraySize] = {};
- CachedBlock Quarantine[Config::SecondaryCacheQuarantineSize] = {};
+ QuarantineBlocks<Config::SecondaryCacheQuarantineSize> Quarantine = {};
};
template <typename Config> class MapAllocator {