From 40daefd3dc56e306f544e383a940885ce035ba51 Mon Sep 17 00:00:00 2001 From: Conrad Pankoff Date: Mon, 2 Sep 2019 15:32:22 +1000 Subject: [PATCH] AK: Abort on unknown printf formatting characters Right now if we encounter an unknown character, printf (and its related functions) fail in a really bad way, where they forget to pull things off the stack. This usually leads to a crash somewhere else, which is hard to debug. This patch makes printf abort as soon as it encounters a formatting character that it can't handle. This is not the optimal solution, but it is an improvement for debugging. --- AK/PrintfImplementation.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index 43e4aa7d63..333a3210f2 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include @@ -349,6 +350,8 @@ template case 'p': ret += print_hex(putch, bufptr, va_arg(ap, u32), *p == 'P', true, false, true, 8); break; + default: + ASSERT_NOT_REACHED(); } } else { putch(bufptr, *p);