diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-01-27 16:27:34 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-01-27 16:27:34 +0100 |
| commit | 4123605aabb4f12bdf829df4a2abda40d62028ee (patch) | |
| tree | 8d9a0d4552e65ac9aa05dbed921f1f4a41524295 /src | |
| parent | f2544509c1796ea2bb120af23b73a94f88d219bc (diff) | |
Fix inlined animated GIFs with NULL name (#897)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Anim_GIF_Image.cxx | 14 |
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); } |
