[iksemel, libdingaling] scan-build: fix multiple dead assignments and dereference of null pointer

This commit is contained in:
Andrey Volk 2020-02-22 01:15:43 +04:00
parent 14913244a3
commit 5e5fd214b5
7 changed files with 6 additions and 13 deletions

View File

@ -32,7 +32,7 @@ static ikschunk *
find_space (ikstack *s, ikschunk *c, size_t size)
{
/* FIXME: dont use *2 after over allocated chunks */
while (1) {
while (c) {
if (c->size - c->used >= size) return c;
if (!c->next) {
if ((c->size * 2) > size) size = c->size * 2;

View File

@ -213,22 +213,16 @@ sax_core (iksparser *prs, char *buf, int len)
goto cont;
} else {
if (c & 0x80) {
unsigned char mask;
if ((c & 0x60) == 0x40) {
prs->uni_max = 2;
mask = 0x1F;
} else if ((c & 0x70) == 0x60) {
prs->uni_max = 3;
mask = 0x0F;
} else if ((c & 0x78) == 0x70) {
prs->uni_max = 4;
mask = 0x07;
} else if ((c & 0x7C) == 0x78) {
prs->uni_max = 5;
mask = 0x03;
} else if ((c & 0x7E) == 0x7C) {
prs->uni_max = 6;
mask = 0x01;
} else {
return IKS_BADXML;
}

View File

@ -36,7 +36,7 @@ test_stack (int cs)
memset (mem, 'x', i);
old = iks_stack_strcat (s, old, 0, buf + i, 1);
}
if (strcmp (old, buf) != 0) {
if (old && strcmp (old, buf) != 0) {
printf ("ikstack strcat bug:\nExpected: %s\n Result: %s\n", buf, old);
exit (1);
}

View File

@ -160,7 +160,7 @@ tagHook (void *udata, char *name, char **atts, int type)
nr = tester.cur->nr_atts;
while (nr) {
flag = 0;
for (i = 0;atts[i]; i+= 2) {
for (i = 0;atts&&atts[i]; i+= 2) {
if (iks_strcmp (atts[i], tester.cur->atts[nr-1]) == 0 && iks_strcmp (atts[i+1], tester.cur->vals[nr-1]) == 0) {
flag = 1;
break;

View File

@ -117,7 +117,7 @@ hash_print (hash *h, char *title_fmt, char *line_fmt)
struct item **tags, *t;
unsigned int i = 0, pos = 0;
tags = calloc (sizeof (struct tag *), h->count);
tags = calloc (sizeof (struct item *), h->count);
for (; i < h->size; i ++) {
for (t = h->table[i]; t; t = t->next) {

View File

@ -207,7 +207,6 @@ serialize_test (char *buf, int len)
unsigned long time;
iks *x;
iksparser *prs;
char *xml;
int err;
prs = iks_dom_new (&x);
@ -228,7 +227,7 @@ serialize_test (char *buf, int len)
t_reset ();
xml = iks_string (iks_stack (x), x);
iks_string (iks_stack (x), x);
time = t_elapsed ();

View File

@ -930,7 +930,7 @@ static int on_disco_default(void *user_data, ikspak *pak)
char *node = NULL;
char *ns = NULL;
ldl_handle_t *handle = user_data;
iks *iq, *query, *tag;
iks *iq = NULL, *query, *tag;
uint8_t send = 0;
int x;