diff --git a/AK/Memory.h b/AK/Memory.h index 45d148f74d..8b5546f729 100644 --- a/AK/Memory.h +++ b/AK/Memory.h @@ -40,3 +40,16 @@ ALWAYS_INLINE void fast_u32_fill(u32* dest, u32 value, size_t count) } #endif } + +namespace AK { +inline void secure_zero(void* ptr, size_t size) +{ + __builtin_memset(ptr, 0, size); + // The memory barrier is here to avoid the compiler optimizing + // away the memset when we rely on it for wiping secrets. + asm volatile("" :: + : "memory"); +} +} + +using AK::secure_zero;