summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2016-11-19 21:08:41 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2016-11-19 21:10:55 (GMT)
commitfaf4c1fb6012941134046db14370f60748184b05 (patch)
tree7ee2edc98702fed681a51d88ab50a4a9a958dca4
parent61a00c3832332bc27b991d3e20702a7f900e5098 (diff)
downloadnetsurf-faf4c1fb6012941134046db14370f60748184b05.tar.gz
netsurf-faf4c1fb6012941134046db14370f60748184b05.tar.bz2
Free and clear icondata to avoid a potential double-free
-rw-r--r--frontends/amiga/bitmap.c9
-rwxr-xr-xfrontends/amiga/bitmap.h10
-rw-r--r--frontends/amiga/icon.c2
3 files changed, 11 insertions, 10 deletions
diff --git a/frontends/amiga/bitmap.c b/frontends/amiga/bitmap.c
index 7609d94..124c116 100644
--- a/frontends/amiga/bitmap.c
+++ b/frontends/amiga/bitmap.c
@@ -730,14 +730,15 @@ void ami_bitmap_set_title(struct bitmap *bm, const char *title)
bm->title = strdup(title);
}
-ULONG *ami_bitmap_get_icondata(struct bitmap *bm)
+void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
{
- return bm->icondata;
+ bm->icondata = icondata;
}
-void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata)
+void ami_bitmap_free_icondata(struct bitmap *bm)
{
- bm->icondata = icondata;
+ if(bm->icondata) FreeVec(bm->icondata);
+ bm->icondata = NULL;
}
bool ami_bitmap_is_nativebm(struct bitmap *bm, struct BitMap *nbm)
diff --git a/frontends/amiga/bitmap.h b/frontends/amiga/bitmap.h
index 771ded4..a32d740 100755
--- a/frontends/amiga/bitmap.h
+++ b/frontends/amiga/bitmap.h
@@ -63,24 +63,24 @@ void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url);
void ami_bitmap_set_title(struct bitmap *bm, const char *title);
/**
- * Get an icondata pointer
+ * Set an icondata pointer
*
* \param bm a bitmap, as returned by bitmap_create()
- * \return pointer to the icondata area
+ * \param icondata a pointer to memory
*
* This function probably shouldn't be here!
*/
-ULONG *ami_bitmap_get_icondata(struct bitmap *bm);
+void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata);
/**
- * Set an icondata pointer
+ * Free an icondata pointer
*
* \param bm a bitmap, as returned by bitmap_create()
* \param icondata a pointer to memory
*
* This function probably shouldn't be here!
*/
-void ami_bitmap_set_icondata(struct bitmap *bm, ULONG *icondata);
+void ami_bitmap_free_icondata(struct bitmap *bm);
/**
* Test if a BitMap is owned by a bitmap.
diff --git a/frontends/amiga/icon.c b/frontends/amiga/icon.c
index bd79a55..fd996ef 100644
--- a/frontends/amiga/icon.c
+++ b/frontends/amiga/icon.c
@@ -543,6 +543,6 @@ void amiga_icon_free(struct DiskObject *dobj)
struct bitmap *bm = dobj->do_Gadget.UserData;
FreeDiskObject(dobj);
- if(bm) FreeVec(ami_bitmap_get_icondata(bm));
+ if(bm) ami_bitmap_free_icondata(bm);
}