summaryrefslogtreecommitdiff
path: root/sys/src/libdraw/subfont.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-03-02 11:01:12 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-03-02 11:01:12 +0100
commit2259f3fb9aebb2973ee2d892bec944f177a41c64 (patch)
tree79dce66d2ebc573ae4e29468ae7d63cc5317da3f /sys/src/libdraw/subfont.c
parentfc1ff7705b339d480f15fa934c7df215158c1901 (diff)
libdraw: font->display->defaultsubfont vs. display->defaultsubfont, dead code, malloc erros
it is possible to have fonts belong to different or no display, so the check for defaultsubfont has to be against font->display, not the global display variable. remove unused freeup() routine. handle strdup() error in allocsubfont() and realloc() error in buildfont().
Diffstat (limited to 'sys/src/libdraw/subfont.c')
-rw-r--r--sys/src/libdraw/subfont.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/src/libdraw/subfont.c b/sys/src/libdraw/subfont.c
index 512418f95..60e128814 100644
--- a/sys/src/libdraw/subfont.c
+++ b/sys/src/libdraw/subfont.c
@@ -10,8 +10,8 @@ allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i
assert(height != 0 /* allocsubfont */);
f = malloc(sizeof(Subfont));
- if(f == 0)
- return 0;
+ if(f == nil)
+ return nil;
f->n = n;
f->height = height;
f->ascent = ascent;
@@ -20,8 +20,12 @@ allocsubfont(char *name, int n, int height, int ascent, Fontchar *info, Image *i
f->ref = 1;
if(name){
f->name = strdup(name);
+ if(f->name == nil){
+ free(f);
+ return nil;
+ }
installsubfont(name, f);
}else
- f->name = 0;
+ f->name = nil;
return f;
}