summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-01-27 16:27:34 +0100
committerMatthias Melcher <github@matthiasm.com>2024-01-27 16:27:34 +0100
commit4123605aabb4f12bdf829df4a2abda40d62028ee (patch)
tree8d9a0d4552e65ac9aa05dbed921f1f4a41524295
parentf2544509c1796ea2bb120af23b73a94f88d219bc (diff)
Fix inlined animated GIFs with NULL name (#897)
-rw-r--r--src/Fl_Anim_GIF_Image.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Fl_Anim_GIF_Image.cxx b/src/Fl_Anim_GIF_Image.cxx
index 155ec4ca2..e6481be73 100644
--- a/src/Fl_Anim_GIF_Image.cxx
+++ b/src/Fl_Anim_GIF_Image.cxx
@@ -1040,8 +1040,16 @@ bool Fl_GIF_Image::is_animated(const char *name) {
bool Fl_Anim_GIF_Image::load(const char *name, const unsigned char *imgdata /* =NULL */, size_t imglength /* =0 */) {
DEBUG(("\nFl_Anim_GIF_Image::load '%s'\n", name));
clear_frames();
- free(name_);
- name_ = name ? fl_strdup(name) : 0;
+ if (name_ != name) {
+ if (name_) {
+ ::free(name_);
+ }
+ if (name) {
+ name_ = fl_strdup(name);
+ } else {
+ name_ = NULL;
+ }
+ }
// as load() can be called multiple times
// we have to replicate the actions of the pixmap destructor here
@@ -1054,7 +1062,7 @@ bool Fl_Anim_GIF_Image::load(const char *name, const unsigned char *imgdata /* =
w(0);
h(0);
- if (name_) {
+ if (name_ || imgdata) {
fi_->load(name, imgdata, imglength);
}