This patch provides a partial fix for bug 2368.
The second image in the cited URL is CMY, and the libraries fail to
convert it. The resulting bitmap is null. It is rendered as a
pink rectangle. If the user tries to export it as a sprite,
riscos_bitmap_save() is called, which immediately attempts a null
dereference, causing a crash (when I tried it, it was a serious
crash that brought the whole machine down).
The simple fix is to test for a null bitmap and, if so, warn the
user and go no further.
This version has support for internationalisation of the error
message, and I've supplied messages in the three languages I can
muster.
Longer term of course we should enhance the libraries so that the
conversion does not fail.
Dave
diff --git a/resources/FatMessages b/resources/FatMessages
index e0e1682..b4aa18b 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -3217,6 +3217,10 @@ fr.all.DirectoryError:répertoire '%s' existe déjÃ
it.all.DirectoryError:La directory '%s' è già esistente
nl.all.DirectoryError:map '%s' bestaat reeds
+en.ro.ObjIsNull:Object is null
+fr.ro.ObjIsNull:L'objet est nul
+de.ro.ObjIsNull:Objekt ist null
+
# Error messages for Amiga version only
en.ami.CompError:Unable to open
de.ami.CompError:Nicht zu öffnen
diff --git a/riscos/bitmap.c b/riscos/bitmap.c
index 384895d..29665f9 100644
--- a/riscos/bitmap.c
+++ b/riscos/bitmap.c
@@ -43,6 +43,7 @@
#include "utils/filename.h"
#include "utils/log.h"
#include "utils/utils.h"
+#include "utils/messages.h"
#include "desktop/plotters.h"
#include "content/content.h"
#include "image/bitmap.h"
@@ -272,6 +273,11 @@ bool riscos_bitmap_save(void *vbitmap, const char *path, unsigned flags)
struct bitmap *bitmap = (struct bitmap *) vbitmap;
os_error *error;
+ if (bitmap == NULL)
+ {
+ warn_user("SaveError", messages_get("ObjIsNull"));
+ return false;
+ }
if (!bitmap->sprite_area) {
riscos_bitmap_get_buffer(bitmap);
}
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!
No comments:
Post a Comment