"Rail" & "Fretwork": avoid crash if can't load image
This commit is contained in:
parent
1973e22e6f
commit
ea63917d0e
3 changed files with 38 additions and 3 deletions
|
|
@ -38,7 +38,8 @@ https://tuxpaint.org/
|
|||
AppData.
|
||||
TOYAMA Shin-ichi <dolphin6k@wmail.plala.or.jp>
|
||||
|
||||
* "Foam" magic tool -- avoid crash if image data cannot be loaded.
|
||||
* Avoid crash in some Magic tools if image data cannot be loaded.
|
||||
(Foam, Fretwork, Rails)
|
||||
Bill Kendrick <bill@newbreedsoftware.com>
|
||||
|
||||
* Localization Updates:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Draws fretwork
|
||||
|
||||
Last updated: April 19, 2023
|
||||
Last updated: November 12, 2023
|
||||
*/
|
||||
|
||||
#include "tp_magic_api.h"
|
||||
|
|
@ -162,6 +162,23 @@ int fretwork_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
fretwork_four_back = IMG_Load(fretwork_images[2]);
|
||||
fretwork_corner_back = IMG_Load(fretwork_images[3]);
|
||||
|
||||
if (fretwork_one == NULL || fretwork_one_back == NULL) {
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[0]);
|
||||
return(0);
|
||||
}
|
||||
if (fretwork_three == NULL || fretwork_three_back == NULL) {
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[1]);
|
||||
return(0);
|
||||
}
|
||||
if (fretwork_four == NULL || fretwork_four_back == NULL) {
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[2]);
|
||||
return(0);
|
||||
}
|
||||
if (fretwork_corner == NULL || fretwork_corner_back == NULL) {
|
||||
fprintf(stderr, "Cannot load %s\n", fretwork_images[3]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
img_w = fretwork_one->w;
|
||||
img_h = fretwork_one->h;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Draw train tracks.
|
||||
|
||||
Last updated: April 19, 2023
|
||||
Last updated: November 12, 2023
|
||||
*/
|
||||
#include "tp_magic_api.h"
|
||||
#include "SDL_image.h"
|
||||
|
|
@ -122,6 +122,23 @@ int rails_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
|||
rails_four = IMG_Load(rails_images[2]);
|
||||
rails_corner = IMG_Load(rails_images[3]);
|
||||
|
||||
if (rails_one == NULL) {
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[0]);
|
||||
return(0);
|
||||
}
|
||||
if (rails_three == NULL) {
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[1]);
|
||||
return(0);
|
||||
}
|
||||
if (rails_four == NULL) {
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[2]);
|
||||
return(0);
|
||||
}
|
||||
if (rails_corner == NULL) {
|
||||
fprintf(stderr, "Can't load image %s\n", rails_images[3]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
img_w = rails_one->w;
|
||||
img_h = rails_one->h;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue