Skip to content

Commit 60fa019

Browse files
authored
Merge pull request signalwire#407 from signalwire/iksemel
[iksemel, libdingaling] scan-build: fix multiple dead assignments and dereference of null pointer
2 parents 1491324 + 5e5fd21 commit 60fa019

File tree

7 files changed

+6
-13
lines changed

7 files changed

+6
-13
lines changed

libs/iksemel/src/ikstack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static ikschunk *
3232
find_space (ikstack *s, ikschunk *c, size_t size)
3333
{
3434
/* FIXME: dont use *2 after over allocated chunks */
35-
while (1) {
35+
while (c) {
3636
if (c->size - c->used >= size) return c;
3737
if (!c->next) {
3838
if ((c->size * 2) > size) size = c->size * 2;

libs/iksemel/src/sax.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,22 +213,16 @@ sax_core (iksparser *prs, char *buf, int len)
213213
goto cont;
214214
} else {
215215
if (c & 0x80) {
216-
unsigned char mask;
217216
if ((c & 0x60) == 0x40) {
218217
prs->uni_max = 2;
219-
mask = 0x1F;
220218
} else if ((c & 0x70) == 0x60) {
221219
prs->uni_max = 3;
222-
mask = 0x0F;
223220
} else if ((c & 0x78) == 0x70) {
224221
prs->uni_max = 4;
225-
mask = 0x07;
226222
} else if ((c & 0x7C) == 0x78) {
227223
prs->uni_max = 5;
228-
mask = 0x03;
229224
} else if ((c & 0x7E) == 0x7C) {
230225
prs->uni_max = 6;
231-
mask = 0x01;
232226
} else {
233227
return IKS_BADXML;
234228
}

libs/iksemel/test/tst-ikstack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test_stack (int cs)
3636
memset (mem, 'x', i);
3737
old = iks_stack_strcat (s, old, 0, buf + i, 1);
3838
}
39-
if (strcmp (old, buf) != 0) {
39+
if (old && strcmp (old, buf) != 0) {
4040
printf ("ikstack strcat bug:\nExpected: %s\n Result: %s\n", buf, old);
4141
exit (1);
4242
}

libs/iksemel/test/tst-sax.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ tagHook (void *udata, char *name, char **atts, int type)
160160
nr = tester.cur->nr_atts;
161161
while (nr) {
162162
flag = 0;
163-
for (i = 0;atts[i]; i+= 2) {
163+
for (i = 0;atts&&atts[i]; i+= 2) {
164164
if (iks_strcmp (atts[i], tester.cur->atts[nr-1]) == 0 && iks_strcmp (atts[i+1], tester.cur->vals[nr-1]) == 0) {
165165
flag = 1;
166166
break;

libs/iksemel/tools/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ hash_print (hash *h, char *title_fmt, char *line_fmt)
117117
struct item **tags, *t;
118118
unsigned int i = 0, pos = 0;
119119

120-
tags = calloc (sizeof (struct tag *), h->count);
120+
tags = calloc (sizeof (struct item *), h->count);
121121

122122
for (; i < h->size; i ++) {
123123
for (t = h->table[i]; t; t = t->next) {

libs/iksemel/tools/iksperf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ serialize_test (char *buf, int len)
207207
unsigned long time;
208208
iks *x;
209209
iksparser *prs;
210-
char *xml;
211210
int err;
212211

213212
prs = iks_dom_new (&x);
@@ -228,7 +227,7 @@ serialize_test (char *buf, int len)
228227

229228
t_reset ();
230229

231-
xml = iks_string (iks_stack (x), x);
230+
iks_string (iks_stack (x), x);
232231

233232
time = t_elapsed ();
234233

libs/libdingaling/src/libdingaling.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ static int on_disco_default(void *user_data, ikspak *pak)
930930
char *node = NULL;
931931
char *ns = NULL;
932932
ldl_handle_t *handle = user_data;
933-
iks *iq, *query, *tag;
933+
iks *iq = NULL, *query, *tag;
934934
uint8_t send = 0;
935935
int x;
936936

0 commit comments

Comments
 (0)