Skip to content

Commit

Permalink
PR/470: Fix undefined behaviors.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoulasc committed Jul 27, 2015
1 parent 372d236 commit cd85f48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/apprentice.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "file.h"

#ifndef lint
FILE_RCSID("@(#)$File: apprentice.c,v 1.232 2015/04/09 20:01:40 christos Exp $")
FILE_RCSID("@(#)$File: apprentice.c,v 1.233 2015/06/10 00:57:41 christos Exp $")
#endif /* lint */

#include "magic.h"
Expand Down Expand Up @@ -1348,8 +1348,9 @@ apprentice_load(struct magic_set *ms, const char *fn, int action)
}
i = set_text_binary(ms, mset[j].me, mset[j].count, i);
}
qsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),
apprentice_sort);
if (mset[j].me)
qsort(mset[j].me, mset[j].count, sizeof(*mset[j].me),
apprentice_sort);

/*
* Make sure that any level 0 "default" line is last
Expand Down Expand Up @@ -3209,9 +3210,10 @@ file_pstring_length_size(const struct magic *m)
}
}
protected size_t
file_pstring_get_length(const struct magic *m, const char *s)
file_pstring_get_length(const struct magic *m, const char *ss)
{
size_t len = 0;
const unsigned char *s = (const unsigned char *)ss;

switch (m->str_flags & PSTRING_LEN) {
case PSTRING_1_LE:
Expand Down

0 comments on commit cd85f48

Please sign in to comment.