summaryrefslogtreecommitdiff
path: root/render/html.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-04-26 00:32:42 +0100
committerVincent Sanders <vince@kyllikki.org>2015-04-26 00:32:42 +0100
commit3cabd331ee1b638b02334155f831a8715fea399a (patch)
treef6b292c947ea9f0e10f8004c3b42c90c80820887 /render/html.c
parente64d48980e38448eeb83daa8659788d48f845692 (diff)
downloadnetsurf-3cabd331ee1b638b02334155f831a8715fea399a.tar.gz
netsurf-3cabd331ee1b638b02334155f831a8715fea399a.tar.bz2
Ensure result of ftell is checked for errors
The ftell call in the html renderer handling of drag and drop was not checking its return value for errors which could have resulted in attempting to read -1 bytes. coverity 1251038
Diffstat (limited to 'render/html.c')
-rw-r--r--render/html.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/render/html.c b/render/html.c
index 5fb2feabd..e8692a0a7 100644
--- a/render/html.c
+++ b/render/html.c
@@ -1934,6 +1934,12 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file)
file_len = ftell(fp);
fseek(fp, 0, SEEK_SET);
+ if ((long)file_len == -1) {
+ /* unable to get file length, but drop was for us */
+ fclose(fp);
+ return true;
+ }
+
/* Allocate buffer for file data */
buffer = malloc(file_len + 1);
if (buffer == NULL) {