aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile
diff options
context:
space:
mode:
authorAndrew Hannam <Andrew Hannam>2016-07-10 10:42:21 +1000
committerAndrew Hannam <Andrew Hannam>2016-07-10 10:42:21 +1000
commit9ac3c368b4de8e2f38bad56262c75d3310c8814b (patch)
tree973fb9bf591398e6826a25f64e9975cc5f06a51b /src/gfile
parented9b268d5bce5fe6d703bc785034191312782db0 (diff)
downloaduGFX-9ac3c368b4de8e2f38bad56262c75d3310c8814b.tar.gz
uGFX-9ac3c368b4de8e2f38bad56262c75d3310c8814b.tar.bz2
uGFX-9ac3c368b4de8e2f38bad56262c75d3310c8814b.zip
Add gwinPrintg() and fix null pointer handling in sprintg()
Diffstat (limited to 'src/gfile')
-rw-r--r--src/gfile/gfile_fs_strings.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gfile/gfile_fs_strings.c b/src/gfile/gfile_fs_strings.c
index 86c536d7..fcc118ec 100644
--- a/src/gfile/gfile_fs_strings.c
+++ b/src/gfile/gfile_fs_strings.c
@@ -22,12 +22,18 @@ static int StringRead(GFILE *f, void *buf, int size) {
int res;
char *p;
+ if (!f->obj)
+ return 0;
+
p = ((char *)f->obj) + f->pos;
for(res = 0; res < size && *p; res++, p++, buf = ((char *)buf)+1)
((char *)buf)[0] = *p;
return res;
}
static int StringWrite(GFILE *f, const void *buf, int size) {
+ if (!f->obj)
+ return 0;
+
if ((f->flags & GFILEFLG_APPEND)) {
while(((char *)f->obj)[f->pos])
f->pos++;
@@ -50,7 +56,7 @@ static const GFILEVMT StringVMT = {
};
static void gfileOpenStringFromStaticGFILE(GFILE *f, char *str) {
- if ((f->flags & GFILEFLG_TRUNC))
+ if ((f->flags & GFILEFLG_TRUNC) && str)
str[0] = 0;
f->vmt = &StringVMT;
f->obj = str;
@@ -62,7 +68,7 @@ GFILE *gfileOpenString(char *str, const char *mode) {
GFILE *f;
// Get an empty file and set the flags
- if (!(f = _gfileFindSlot(mode)))
+ if (!str || !(f = _gfileFindSlot(mode)))
return 0;
// File is open - fill in all the details