Uninitialized read: make the pointer non-volatile rather than the buffer
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/programs/test/metatest.c b/programs/test/metatest.c
index ce866ed..5e6a15f 100644
--- a/programs/test/metatest.c
+++ b/programs/test/metatest.c
@@ -96,12 +96,13 @@
void read_uninitialized_stack(const char *name)
{
(void) name;
- volatile char buf[1];
+ char buf[1];
if (false_but_the_compiler_does_not_know) {
buf[0] = '!';
}
- if (*buf != 0) {
- mbedtls_printf("%u\n", (unsigned) *buf);
+ char *volatile p = buf;
+ if (*p != 0) {
+ mbedtls_printf("%u\n", (unsigned) *p);
}
}