Mercurial > hg > batmud > maputils
changeset 805:b924d9c9d58f
Fix some NULL pointer dereferences in location list handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 17 Jul 2009 22:11:21 +0000 |
parents | eaf1b4e6ea83 |
children | 1f50c8edd739 |
files | mkloc.c |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mkloc.c Fri Jul 17 22:02:05 2009 +0000 +++ b/mkloc.c Fri Jul 17 22:11:21 2009 +0000 @@ -272,6 +272,7 @@ void printEscString(FILE *f, char *s) { char *p = s; + if (s == NULL) return; while (*p) { switch (*p) { @@ -289,6 +290,7 @@ void fprintfe(FILE *f, const char *s) { const char *p = s; + if (s == NULL) return; while (*p) { switch (*p) { @@ -317,16 +319,16 @@ tmp->dir = dir; tmp->flags = flags; for (i = 0; i < LOC_MAX_NAMES; i++) { - if (names[i]) { + if (names != NULL && names[i] != NULL) { tmp->names[tmp->nnames] = th_strdup(names[i]); tmp->nnames++; } - if (coders[i]) { + if (coders != NULL && coders[i] != NULL) { tmp->coders[tmp->ncoders] = th_strdup(coders[i]); tmp->ncoders++; } } - if (added) { + if (added != NULL) { memcpy(&(tmp->added), added, sizeof(tmp->added)); tmp->addedValid = addedValid; } else { @@ -344,7 +346,7 @@ l->locations = (locinfo_t **) th_realloc(l->locations, sizeof(locinfo_t*) * (l->numLocations+1)); - if (!l->locations) return FALSE; + if (l->locations == NULL) return FALSE; l->locations[l->numLocations] = tmp; l->numLocations++;