From 57e056a22c59149455a889556bee873bf4e05d43 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 18 Apr 2026 10:54:56 -0600 Subject: [PATCH] [vector] Return nullptr from paint get_funcs for invalid format Assisted-by: Claude Opus 4.6 (1M context) --- src/hb-vector-draw.cc | 20 ++++++++------------ src/hb-vector-paint.cc | 3 ++- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/hb-vector-draw.cc b/src/hb-vector-draw.cc index c2f7512d3..ad411676d 100644 --- a/src/hb-vector-draw.cc +++ b/src/hb-vector-draw.cc @@ -121,16 +121,7 @@ static struct hb_vector_draw_pdf_funcs_lazy_loader_t } static_vector_draw_pdf_funcs; static inline void free_static_vector_draw_pdf_funcs () { static_vector_draw_pdf_funcs.free_instance (); } -static hb_draw_funcs_t * -hb_vector_draw_funcs_get (hb_vector_format_t format) -{ - switch (format) - { - case HB_VECTOR_FORMAT_SVG: return static_vector_draw_svg_funcs.get_unconst (); - case HB_VECTOR_FORMAT_PDF: return static_vector_draw_pdf_funcs.get_unconst (); - case HB_VECTOR_FORMAT_INVALID: default: return nullptr; - } -} + /** * hb_vector_draw_create_or_fail: @@ -459,9 +450,14 @@ hb_vector_draw_get_format (const hb_vector_draw_t *draw) * XSince: REPLACEME */ hb_draw_funcs_t * -hb_vector_draw_get_funcs (const hb_vector_draw_t *draw HB_UNUSED) +hb_vector_draw_get_funcs (const hb_vector_draw_t *draw) { - return hb_vector_draw_funcs_get (draw->format); + switch (draw ? draw->format : HB_VECTOR_FORMAT_INVALID) + { + case HB_VECTOR_FORMAT_SVG: return static_vector_draw_svg_funcs.get_unconst (); + case HB_VECTOR_FORMAT_PDF: return static_vector_draw_pdf_funcs.get_unconst (); + case HB_VECTOR_FORMAT_INVALID: default: return nullptr; + } } /** diff --git a/src/hb-vector-paint.cc b/src/hb-vector-paint.cc index 4a58d22cc..dad289946 100644 --- a/src/hb-vector-paint.cc +++ b/src/hb-vector-paint.cc @@ -520,9 +520,10 @@ hb_vector_paint_get_funcs (const hb_vector_paint_t *paint) case HB_VECTOR_FORMAT_PDF: return hb_vector_paint_pdf_funcs_get (); case HB_VECTOR_FORMAT_SVG: + return hb_vector_paint_svg_funcs_get (); case HB_VECTOR_FORMAT_INVALID: default: - return hb_vector_paint_svg_funcs_get (); + return nullptr; } }