edox: Fix clang-analyzer complaints

This commit is contained in:
Kim Woelders 2020-01-25 17:15:39 +01:00
parent 72a86722a7
commit 910a27dd56
3 changed files with 23 additions and 21 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2007-2014 Kim Woelders * Copyright (C) 2007-2020 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -705,6 +705,8 @@ main(int argc, char **argv)
} }
} }
done: done:
free(page_hist);
free(s);
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2007-2011 Kim Woelders * Copyright (C) 2007-2020 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -115,7 +115,7 @@ AddPage(Object * obj)
page[num_pages - 1].linkg = DEFAULT_LINKCOLOR_G; page[num_pages - 1].linkg = DEFAULT_LINKCOLOR_G;
page[num_pages - 1].linkb = DEFAULT_LINKCOLOR_B; page[num_pages - 1].linkb = DEFAULT_LINKCOLOR_B;
if ((obj) && (obj->type == PAGE)) if ((obj) && (obj->type == PAGE) && (obj->object))
{ {
Page *pg; Page *pg;
@ -153,7 +153,8 @@ BuildObj(Object * obj, char *var, char *param)
switch (obj->type) switch (obj->type)
{ {
case IMG: case IMG:
if (!obj->object) img = obj->object;
if (!img)
{ {
img = EMALLOC(Img_, 1); img = EMALLOC(Img_, 1);
obj->object = img; obj->object = img;
@ -182,7 +183,8 @@ BuildObj(Object * obj, char *var, char *param)
case BR: case BR:
break; break;
case FONT: case FONT:
if (!obj->object) fn = obj->object;
if (!fn)
{ {
fn = EMALLOC(Font_, 1); fn = EMALLOC(Font_, 1);
obj->object = fn; obj->object = fn;
@ -212,7 +214,8 @@ BuildObj(Object * obj, char *var, char *param)
} }
break; break;
case P: case P:
if (!obj->object) p = obj->object;
if (!p)
{ {
p = EMALLOC(P_, 1); p = EMALLOC(P_, 1);
obj->object = p; obj->object = p;
@ -228,7 +231,8 @@ BuildObj(Object * obj, char *var, char *param)
case TEXT: case TEXT:
break; break;
case PAGE: case PAGE:
if (!obj->object) pg = obj->object;
if (!pg)
{ {
pg = EMALLOC(Page, 1); pg = EMALLOC(Page, 1);
obj->object = pg; obj->object = pg;
@ -456,6 +460,7 @@ GetObjects(FILE * f)
in_para = 0; in_para = 0;
} }
obj.type = P;
obj.object = NULL; obj.object = NULL;
for (;;) for (;;)
{ {
@ -465,6 +470,7 @@ GetObjects(FILE * f)
if (txt) if (txt)
{ {
obj.type = TEXT; obj.type = TEXT;
free(obj.object);
obj.object = (void *)txt; obj.object = (void *)txt;
} }
else else
@ -551,7 +557,6 @@ CalcOffset(Page * pg, int col_w, int x, int y, int th, int *pxspace, int *poff)
Img_ *img; Img_ *img;
int j; int j;
xspace = col_w;
off = 0; off = 0;
sx = x + off; sx = x + off;
sy = y; sy = y;
@ -731,15 +736,13 @@ RenderPage(Window win, int page_num, int w, int h)
int spaceflag, oldwc = 0, linkwc; int spaceflag, oldwc = 0, linkwc;
wd[0] = 0; wd[0] = 0;
spaceflag = 1;
#ifdef USE_WORD_MB #ifdef USE_WORD_MB
if (MB_CUR_MAX > 1) /* If multibyte locale,... */ if (MB_CUR_MAX > 1) /* If multibyte locale,... */
word_mb(txt, wc, wd, &spaceflag); word_mb(txt, wc, wd, &spaceflag);
else else
#endif #endif
{ word(txt, wc, wd);
word(txt, wc, wd);
spaceflag = 1;
}
if (!wd[0]) if (!wd[0])
eol = 1; eol = 1;
@ -768,14 +771,12 @@ RenderPage(Window win, int page_num, int w, int h)
islink = 0; islink = 0;
wc = oldwc; wc = oldwc;
#ifdef USE_WORD_MB #ifdef USE_WORD_MB
spaceflag = 1;
if (MB_CUR_MAX > 1) if (MB_CUR_MAX > 1)
word_mb(txt, wc - 1, wd, &spaceflag); word_mb(txt, wc - 1, wd, &spaceflag);
else else
#endif #endif
{ word(txt, wc - 1, wd);
word(txt, wc - 1, wd);
spaceflag = 1;
}
} }
else else
{ {

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
* Copyright (C) 2007-2018 Kim Woelders * Copyright (C) 2007-2020 Kim Woelders
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to * of this software and associated documentation files (the "Software"), to
@ -224,15 +224,14 @@ TextDraw(TextState * ts, Window win, char *text,
XGCValues gcv; XGCValues gcv;
static GC gc = 0; static GC gc = 0;
if (!ts)
return;
lines = TextGetLines(text, &num_lines); lines = TextGetLines(text, &num_lines);
if (!lines) if (!lines)
return; return;
if (!ts)
return;
TextStateLoadFont(ts); TextStateLoadFont(ts);
xx = x;
yy = y; yy = y;
if (!gc) if (!gc)