summaryrefslogtreecommitdiff
path: root/image/gif.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2012-10-25 11:12:41 +0100
committerVincent Sanders <vince@netsurf-browser.org>2012-10-25 11:12:41 +0100
commitbaf50cec89d10055217a3bb210d389694fb1d389 (patch)
tree98ba96f23f98ceecaf02fbc2e016b297a50c9a25 /image/gif.c
parent0b7db9b47adaf56ae937415040cf585a07eaf8cb (diff)
downloadnetsurf-baf50cec89d10055217a3bb210d389694fb1d389.tar.gz
netsurf-baf50cec89d10055217a3bb210d389694fb1d389.tar.bz2
make image content handlers title setting use the heap instead of the stack and remove the possibility of buffer overruns
Diffstat (limited to 'image/gif.c')
-rw-r--r--image/gif.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/image/gif.c b/image/gif.c
index a33f56200..704c9710b 100644
--- a/image/gif.c
+++ b/image/gif.c
@@ -242,7 +242,7 @@ static bool nsgif_convert(struct content *c)
union content_msg_data msg_data;
const char *data;
unsigned long size;
- char title[512];
+ char *title;
/* Get the animation */
data = content__get_source_data(c, &size);
@@ -275,14 +275,19 @@ static bool nsgif_convert(struct content *c)
return false;
}
- /* Store our content width and description */
+ /* Store our content width, height and calculate size */
c->width = gif->gif->width;
c->height = gif->gif->height;
- snprintf(title, sizeof(title), messages_get("GIFTitle"),
+ c->size += (gif->gif->width * gif->gif->height * 4) + 16 + 44;
+
+ /* set title text */
+ title = messages_get_buff("GIFTitle",
nsurl_access_leaf(llcache_handle_get_url(c->llcache)),
c->width, c->height);
- content__set_title(c, title);
- c->size += (gif->gif->width * gif->gif->height * 4) + 16 + 44;
+ if (title != NULL) {
+ content__set_title(c, title);
+ free(title);
+ }
/* Schedule the animation if we have one */
gif->current_frame = 0;