diff options
author | Steve Fryatt <steve@stevefryatt.org.uk> | 2011-10-18 21:41:45 +0000 |
---|---|---|
committer | Steve Fryatt <steve@stevefryatt.org.uk> | 2011-10-18 21:41:45 +0000 |
commit | 67c9262403635a1689401d690a6bbf0fd95fb1d7 (patch) | |
tree | f6c9c721acc692f8360d3fbb2b653f51438d28be /riscos | |
parent | 1dc36241d698da8faadd7d5a66c4b310971448a4 (diff) | |
download | netsurf-67c9262403635a1689401d690a6bbf0fd95fb1d7.tar.gz netsurf-67c9262403635a1689401d690a6bbf0fd95fb1d7.tar.bz2 |
Ensure file content is terminated (bug #1866212).
svn path=/trunk/netsurf/; revision=13070
Diffstat (limited to 'riscos')
-rw-r--r-- | riscos/window.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/riscos/window.c b/riscos/window.c index de3617db4..6defacf36 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -4315,7 +4315,11 @@ bool ro_gui_window_import_text(struct gui_window *g, const char *filename, return true; /* was for us, but it didn't work! */ } - buf = malloc(size); + /* Allocate one byte more than needed to ensure that the buffer is + * always terminated, regardless of file contents. + */ + + buf = calloc(size + 1, sizeof(char)); if (!buf) { warn_user("NoMemory", NULL); return true; @@ -4323,6 +4327,7 @@ bool ro_gui_window_import_text(struct gui_window *g, const char *filename, error = xosfile_load_stamped(filename, (byte*)buf, NULL, NULL, NULL, NULL, NULL); + if (error) { LOG(("xosfile_load_stamped: 0x%x:%s", error->errnum, error->errmess)); |