summaryrefslogtreecommitdiff
path: root/riscos/wimp.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-08-17 23:41:29 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-08-17 23:41:29 +0000
commitc6eeed815e1871bd9a64bd54fd3e866e54882a05 (patch)
tree8f203bae5bf06149d4f7d7a58fc2f09b36bfc25f /riscos/wimp.c
parent465c7204b9a0bf01429920c2f56b4b51b62c89a2 (diff)
downloadnetsurf-c6eeed815e1871bd9a64bd54fd3e866e54882a05.tar.gz
netsurf-c6eeed815e1871bd9a64bd54fd3e866e54882a05.tar.bz2
Fix buffer overrun & squash compiler warning.
svn path=/trunk/netsurf/; revision=2864
Diffstat (limited to 'riscos/wimp.c')
-rw-r--r--riscos/wimp.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/riscos/wimp.c b/riscos/wimp.c
index 1636a412c..d1c0fd1fc 100644
--- a/riscos/wimp.c
+++ b/riscos/wimp.c
@@ -949,7 +949,9 @@ bool ro_gui_wimp_check_window_furniture(wimp_w w, wimp_window_flags mask) {
* \return pointer to family name
*/
-void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_style *pstyle) {
+void ro_gui_wimp_desktop_font(char *family, size_t bufsize,
+ int *psize, rufl_style *pstyle)
+{
rufl_style style = rufl_WEIGHT_400;
bool got_family = false;
char *buf = NULL;
@@ -981,7 +983,8 @@ void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_sty
}
if (psize) {
- error = xfont_read_defn(fh, buf, &ptx, &pty, NULL, NULL, NULL, NULL);
+ error = xfont_read_defn(fh, buf,
+ &ptx, &pty, NULL, NULL, NULL, NULL);
if (error) {
LOG(("xfont_read_defn: 0x%x: %s",
error->errnum, error->errmess));
@@ -990,7 +993,7 @@ void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_sty
*psize = max(ptx, pty);
}
- error = xfont_read_identifier(fh, buf, &used);
+ error = xfont_read_identifier(fh, buf, NULL);
if (error) {
LOG(("xfont_read_identifier: 0x%x: %s",
error->errnum, error->errmess));
@@ -1022,7 +1025,7 @@ void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_sty
p = q;
while (*p > ' ' && *p != '\\') {
char *q;
- int m = 0;
+ unsigned int m = 0;
if (*p == '.') p++;
q = p; while (*q > ' ' && *q != '.' && *q != '\\') q++;
@@ -1045,9 +1048,8 @@ void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_sty
while (*p > ' ' && *p != '\\') p++;
}
- free(buf);
-
if (got_family) {
+ free(buf);
if (pstyle) *pstyle = style;
return;
}
@@ -1055,7 +1057,12 @@ void ro_gui_wimp_desktop_font(char *family, size_t bufsize, int *psize, rufl_sty
failsafe:
free(buf);
- memcpy(family, "Homerton", 9);
+ if (bufsize >= 9) {
+ memcpy(family, "Homerton", 9);
+ } else {
+ /** \todo what to do here? */
+ assert(0);
+ }
if (psize) *psize = 12*16;
if (pstyle) *pstyle = rufl_WEIGHT_400;