[Concept,1/4] video: truetype: Fix uninitialised bbox on empty text

Message ID 20260208214411.3445278-2-sjg@u-boot.org
State New
Headers
Series Fix truetype bbox init and improve pager robustness |

Commit Message

Simon Glass Feb. 8, 2026, 9:44 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When truetype_measure() is called with empty text, it returns early
without initialising the bbox fields. This causes scene_obj_get_hw() to
return garbage values (uninitialised stack memory) for the height,
leading to intermittent test failures.

Initialise all bbox fields to 0 before the early return when text is
empty.

Fixes: adf54041976c ("console: Allow measuring the bounding box of text")
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 drivers/video/console_truetype.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 913ed4208e4..8ca0308942b 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1021,8 +1021,13 @@  static int truetype_measure(struct udevice *dev, const char *name, uint size,
 		return log_msg_ret("sel", ret);
 
 	bbox->valid = false;
-	if (!*text)
+	if (!*text) {
+		bbox->x0 = 0;
+		bbox->y0 = 0;
+		bbox->x1 = 0;
+		bbox->y1 = 0;
 		return 0;
+	}
 
 	limit = -1;
 	if (pixel_limit != -1)