mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
Ensure we don't access invalid pointers
This commit is contained in:
parent
215d1bec58
commit
8a7d030af7
@ -59,7 +59,7 @@ struct bitmap {
|
||||
PLANEPTR native_mask;
|
||||
Object *dto;
|
||||
struct nsurl *url; /* temporary storage space */
|
||||
const char *title; /* temporary storage space */
|
||||
char *title; /* temporary storage space */
|
||||
ULONG *icondata; /* for appicons */
|
||||
};
|
||||
|
||||
@ -143,10 +143,16 @@ void amiga_bitmap_destroy(void *bitmap)
|
||||
|
||||
if(bm->native_mask) FreeRaster(bm->native_mask, bm->width, bm->height);
|
||||
FreeVec(bm->pixdata);
|
||||
|
||||
if(bm->url) nsurl_unref(bm->url);
|
||||
if(bm->title) free(bm->title);
|
||||
|
||||
bm->pixdata = NULL;
|
||||
bm->nativebm = NULL;
|
||||
bm->native_mask = NULL;
|
||||
bm->dto = NULL;
|
||||
bm->url = NULL;
|
||||
bm->title = NULL;
|
||||
|
||||
ami_misc_itempool_free(pool_bitmap, bm, sizeof(struct bitmap));
|
||||
bm = NULL;
|
||||
@ -644,12 +650,14 @@ static nserror bitmap_render(struct bitmap *bitmap, hlcache_handle *content)
|
||||
|
||||
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url)
|
||||
{
|
||||
bm->url = url;
|
||||
if(bm->url != NULL) return;
|
||||
bm->url = nsurl_ref(url);
|
||||
}
|
||||
|
||||
void ami_bitmap_set_title(struct bitmap *bm, const char *title)
|
||||
{
|
||||
bm->title = title;
|
||||
if(bm->title != NULL) return;
|
||||
bm->title = strdup(title);
|
||||
}
|
||||
|
||||
ULONG *ami_bitmap_get_icondata(struct bitmap *bm)
|
||||
|
@ -46,7 +46,8 @@ struct bitmap *ami_bitmap_from_datatype(char *filename);
|
||||
* \param bm a bitmap, as returned by bitmap_create()
|
||||
* \param title a pointer to a title string
|
||||
*
|
||||
* It is assumed that this is freed elsewhere after the bitmap is destroyed.
|
||||
* A reference will be kept by the bitmap object.
|
||||
* The URL can only ever be set once for a bitmap.
|
||||
*/
|
||||
void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url);
|
||||
|
||||
@ -56,7 +57,8 @@ void ami_bitmap_set_url(struct bitmap *bm, struct nsurl *url);
|
||||
* \param bm a bitmap, as returned by bitmap_create()
|
||||
* \param title a pointer to a title string
|
||||
*
|
||||
* It is assumed that this is freed elsewhere after the bitmap is destroyed.
|
||||
* This is copied by the bitmap object.
|
||||
* The title can only ever be set once for a bitmap.
|
||||
*/
|
||||
void ami_bitmap_set_title(struct bitmap *bm, const char *title);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user