From ab4d79a686425baadc8c00911cf4e46480a4939b Mon Sep 17 00:00:00 2001 From: GenevensiS <66968533+G-e-n-e-v-e-n-s-i-S@users.noreply.github.com> Date: Mon, 19 Jan 2026 17:21:42 +0100 Subject: [PATCH] prevent crash in crop_image function --- data/ch-s.mse-locale/locale | 6 +++++- data/ch-t.mse-locale/locale | 6 +++++- data/da.mse-locale/locale | 5 ++++- data/de.mse-locale/locale | 4 +++- data/en.mse-locale/locale | 2 ++ data/es.mse-locale/locale | 6 +++++- data/fr.mse-locale/locale | 4 +++- data/it.mse-locale/locale | 4 +++- data/jp.mse-locale/locale | 6 +++++- data/ko.mse-locale/locale | 6 +++++- data/pl.mse-locale/locale | 6 +++++- data/pt-br.mse-locale/locale | 4 +++- data/ru.mse-locale/locale | 5 ++++- src/gfx/generated_image.cpp | 8 ++++++-- 14 files changed, 58 insertions(+), 14 deletions(-) diff --git a/data/ch-s.mse-locale/locale b/data/ch-s.mse-locale/locale index c2af934c..d2662696 100644 --- a/data/ch-s.mse-locale/locale +++ b/data/ch-s.mse-locale/locale @@ -1067,9 +1067,13 @@ error: coordinates for blending overlap: 坐标混合重叠 images used for blending must have the same size: 边框用图像必须使用相同大小 #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: 没有为 %s 指定游戏类型 no stylesheet specified for the set: 没有为套牌制定样式表 stylesheet and set refer to different game: diff --git a/data/ch-t.mse-locale/locale b/data/ch-t.mse-locale/locale index 7ce1922e..618103fc 100644 --- a/data/ch-t.mse-locale/locale +++ b/data/ch-t.mse-locale/locale @@ -1065,9 +1065,13 @@ error: coordinates for blending overlap: 坐標混合重疊 images used for blending must have the same size: 邊框用圖像必須使用相同大小 #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: 沒有為 %s 指定游戲類型 no stylesheet specified for the set: 沒有為套牌制定樣式表 stylesheet and set refer to different game: diff --git a/data/da.mse-locale/locale b/data/da.mse-locale/locale index 429975a3..a3b0df08 100644 --- a/data/da.mse-locale/locale +++ b/data/da.mse-locale/locale @@ -1092,10 +1092,13 @@ error: #TODO: Localize images used for blending must have the same size: Images used for blending must have the same size #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files #TODO: Localize Section + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: No game specified for the %s no stylesheet specified for the set: No stylesheet specified for the set stylesheet and set refer to different game: diff --git a/data/de.mse-locale/locale b/data/de.mse-locale/locale index 88f6272c..cd1fc9f5 100644 --- a/data/de.mse-locale/locale +++ b/data/de.mse-locale/locale @@ -1007,9 +1007,11 @@ error: # image stuff coordinates for blending overlap: Koordinaten zum Blenden überlappen sich images used for blending must have the same size: Bilder müssen zum Mischen die selbe Größe haben. - no card fields: Das Spiel '%s' hat keine Kartenfelder. Definieren Sie mindestens ein Kartenfeld. + negative image width: Bild mit Breite Null oder negativer Breite, erstellt in der Funktion '%s' + negative image height: Bild mit Höhe Null oder negativer Höhe, erstellt in der Funktion '%s' # error from files + no card fields: Das Spiel '%s' hat keine Kartenfelder. Definieren Sie mindestens ein Kartenfeld. no game specified: Kein Spiel für %s gewählt no stylesheet specified for the set: Kein Stylesheet für diese Edition gewählt stylesheet and set refer to different game: diff --git a/data/en.mse-locale/locale b/data/en.mse-locale/locale index 72642cf9..aa650f55 100644 --- a/data/en.mse-locale/locale +++ b/data/en.mse-locale/locale @@ -1009,6 +1009,8 @@ error: # image stuff coordinates for blending overlap: Coordinates for blending overlap images used for blending must have the same size: Images used for blending must have the same size + negative image width: Image with zero or negative width created in function '%s' + negative image height: Image with zero or negative height created in function '%s' # error from files no card fields: Game '%s' does not have any card fields. Define at least one card field. diff --git a/data/es.mse-locale/locale b/data/es.mse-locale/locale index 2cb2f4cd..1548b02e 100644 --- a/data/es.mse-locale/locale +++ b/data/es.mse-locale/locale @@ -1068,9 +1068,13 @@ error: coordinates for blending overlap: Coordenadas para la mezcla (blending) solapada images used for blending must have the same size: Las imagenes utilizadas para la mezcla (blending) deben tener el mismo tamaño #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: Ningún juego especificado para el %s no stylesheet specified for the set: Ho hay hojas de estilo (stylesheet) especificadas para el Set stylesheet and set refer to different game: diff --git a/data/fr.mse-locale/locale b/data/fr.mse-locale/locale index bef59404..77ada32a 100644 --- a/data/fr.mse-locale/locale +++ b/data/fr.mse-locale/locale @@ -1008,9 +1008,11 @@ error: # image stuff coordinates for blending overlap: Coordonnées pour la superposition du mélange images used for blending must have the same size: Les images utilisées pour le mélange doivent avoir la même taille - no card fields: Le jeu '%s' ne contient aucun champ de carte. Définissez au moins un champ de carte. + negative image width: Image de largeur nulle ou négative créée par la fonction '%s' + negative image height: Image de hauteur nulle ou négative créée par la fonction '%s' # error from files + no card fields: Le jeu '%s' ne contient aucun champ de carte. Définissez au moins un champ de carte. no game specified: Pas de jeu spécifié pour le %s no stylesheet specified for the set: Pas de Style spécifié pour le Set stylesheet and set refer to different game: diff --git a/data/it.mse-locale/locale b/data/it.mse-locale/locale index cdd60a40..7260c624 100644 --- a/data/it.mse-locale/locale +++ b/data/it.mse-locale/locale @@ -1008,9 +1008,11 @@ error: # image stuff coordinates for blending overlap: Coordinate per sovrapposizione images used for blending must have the same size: Le immagini sovrapposte devono avere le stesse misure - no card fields: Il gioco '%s' non ha campi carta. Definisci almeno un campo carta. + negative image width: Immagine con larghezza zero o negativa creata nella funzione '%s' + negative image height: Immagine con altezza zero o negativa creata nella funzione '%s' # error from files + no card fields: Il gioco '%s' non ha campi carta. Definisci almeno un campo carta. no game specified: Nessun gioco specificato per il %s no stylesheet specified for the set: Nessuno stile specificato per il set stylesheet and set refer to different game: diff --git a/data/jp.mse-locale/locale b/data/jp.mse-locale/locale index 2b4319a7..07f2f5b2 100644 --- a/data/jp.mse-locale/locale +++ b/data/jp.mse-locale/locale @@ -1068,9 +1068,13 @@ error: coordinates for blending overlap: オーバーラップを混ぜることのための座標 images used for blending must have the same size: 混ざることのために使われたイメージは同じサイズを持たなければなりません #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: のゲームに指定された %s no stylesheet specified for the set: セットのために指定されたスタイルシートはありません stylesheet and set refer to different game: diff --git a/data/ko.mse-locale/locale b/data/ko.mse-locale/locale index 15794c8e..f8e633c1 100644 --- a/data/ko.mse-locale/locale +++ b/data/ko.mse-locale/locale @@ -1074,9 +1074,13 @@ error: coordinates for blending overlap: 블렌딩 오버랩을 위한 좌표 images used for blending must have the same size: 블렌딩에 사용되는 이미지의 크기는 동일해야 합니다. #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: 에 지정된 게임이 없습니다 %s no stylesheet specified for the set: 세트에 지정된 스타일시트가 없습니다 stylesheet and set refer to different game: diff --git a/data/pl.mse-locale/locale b/data/pl.mse-locale/locale index c828fd85..70961246 100644 --- a/data/pl.mse-locale/locale +++ b/data/pl.mse-locale/locale @@ -1124,9 +1124,13 @@ error: coordinates for blending overlap: Współrzędne scalania (blending) nachodzą na siebie images used for blending must have the same size: Obrazy użyte do scalania (blending) muszą mieć ten sam rozmiar #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files + #TODO: Localize + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: Nie podano gry dla %s no stylesheet specified for the set: Nie podano arkusza stylu dla zestawu stylesheet and set refer to different game: diff --git a/data/pt-br.mse-locale/locale b/data/pt-br.mse-locale/locale index 9ddfb363..c8d60fb1 100644 --- a/data/pt-br.mse-locale/locale +++ b/data/pt-br.mse-locale/locale @@ -1009,9 +1009,11 @@ error: # image stuff coordinates for blending overlap: Cordenadas para mistura sobreposição images used for blending must have the same size: Imagens utilizados para a mistura deve ter o mesmo tamanho - no card fields: O jogo '%s' não possui campos de Card. Defina pelo menos um campo de Card. + negative image width: Imagem com largura zero ou negativa criada na função '%s' + negative image height: Imagem com altura zero ou negativa criada na função '%s' # error from files + no card fields: O jogo '%s' não possui campos de Card. Defina pelo menos um campo de Card. no game specified: Não há jogo especificado para o %s no stylesheet specified for the set: Não estilo especificado para a Edição stylesheet and set refer to different game: diff --git a/data/ru.mse-locale/locale b/data/ru.mse-locale/locale index 7e40d141..69b29fc2 100644 --- a/data/ru.mse-locale/locale +++ b/data/ru.mse-locale/locale @@ -1120,10 +1120,13 @@ error: #TODO: Localize images used for blending must have the same size: Images used for blending must have the same size #TODO: Localize - no card fields: Game '%s' does not have any card fields. Define at least one card field. + negative image width: Image with zero or negative width created in function '%s' + #TODO: Localize + negative image height: Image with zero or negative height created in function '%s' # error from files #TODO: Localize Section + no card fields: Game '%s' does not have any card fields. Define at least one card field. no game specified: No game specified for the %s no stylesheet specified for the set: No stylesheet specified for the set stylesheet and set refer to different game: diff --git a/src/gfx/generated_image.cpp b/src/gfx/generated_image.cpp index c66b5087..1ea0e535 100644 --- a/src/gfx/generated_image.cpp +++ b/src/gfx/generated_image.cpp @@ -460,7 +460,9 @@ Image InsertedImage::generate(const Options& opt) { int inserted_x = offset_x < 0 ? 0 : offset_x; int inserted_y = offset_y < 0 ? 0 : offset_y; int width = max(base_x + base_img.GetWidth(), inserted_x + inserted_img.GetWidth()); - int height = max(base_y + base_img.GetHeight(), inserted_y + inserted_img.GetHeight()); + int height = max(base_y + base_img.GetHeight(), inserted_y + inserted_img.GetHeight()); + if (width <= 0) throw ScriptError(_ERROR_1_("negative image width", "insert_image")); + if (height <= 0) throw ScriptError(_ERROR_1_("negative image height", "insert_image")); UInt size = width * height; Image img = wxImage(width, height, false); img.InitAlpha(); @@ -496,7 +498,9 @@ bool InsertedImage::operator == (const GeneratedImage& that) const { // ----------------------------------------------------------------------------- : CropImage -Image CropImage::generate(const Options& opt) { +Image CropImage::generate(const Options& opt) { + if (width <= 0) throw ScriptError(_ERROR_1_("negative image width", "crop_image")); + if (height <= 0) throw ScriptError(_ERROR_1_("negative image height", "crop_image")); UInt size = width * height; Image img = wxImage(width, height, false); img.InitAlpha();