From 578b479998f2be3e5bdaad7ca71d5f1484b0ff01 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Thu, 16 Nov 2023 09:42:34 +0100 Subject: [PATCH] Fix #114892: crash opening old files with text objects Exposed by 16e4eeb9c0. In (rare) occasions, a Curve's `CharInfo` can be NULL. This also crashed going into editmode on affected text objects in previous versions, however opening and rendering these files was still fine. In 4.0, opening those kind of files crashed. It is not entirely clear how this can happen (there are comments in code dating back to 97df61a7e539 mentioning "old file", there might be other reasons, too), still, avoiding the crash on file open seems like good practice. Pull Request: https://projects.blender.org/blender/blender/pulls/114916 --- source/blender/blenloader/intern/versioning_400.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index bc977205f0d..2207766bf02 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -1863,10 +1863,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) const int curvetype = BKE_curve_type_get(curve); if (curvetype == OB_FONT) { CharInfo *info = curve->strinfo; - for (int i = curve->len_char32 - 1; i >= 0; i--, info++) { - if (info->mat_nr > 0) { - /** CharInfo mat_nr used to start at 1, unlike mesh & nurbs, now zero-based. */ - info->mat_nr--; + if (info != nullptr) { + for (int i = curve->len_char32 - 1; i >= 0; i--, info++) { + if (info->mat_nr > 0) { + /** CharInfo mat_nr used to start at 1, unlike mesh & nurbs, now zero-based. */ + info->mat_nr--; + } } } }