CID 22493 Dereference after null check

This commit is contained in:
Enno Rehling 2015-11-04 12:14:12 +01:00
parent 657f5044e5
commit 1a715d6736
1 changed files with 7 additions and 8 deletions

View File

@ -1848,18 +1848,16 @@ const faction * f)
{
int i, bytes;
const char *name, *bname, *billusion = NULL;
const struct locale *lang = NULL;
const struct locale *lang;
char buffer[8192], *bufp = buffer;
message *msg;
size_t size = sizeof(buffer) - 1;
newline(out);
if (f)
assert(f);
lang = f->locale;
newline(out);
bytes =
_snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(f->locale,
_snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(lang,
"nr_size"), b->size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1881,7 +1879,7 @@ const faction * f)
}
if (b->size < b->type->maxsize) {
bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_building_inprogress"), size);
bytes = (int)strlcpy(bufp, LOC(lang, "nr_building_inprogress"), size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -1889,7 +1887,7 @@ const faction * f)
if (b->besieged > 0 && sr->mode >= see_lighthouse) {
msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged,
b->besieged - b->size * SIEGEFACTOR);
bytes = (int)nr_render(msg, f->locale, bufp, size, f);
bytes = (int)nr_render(msg, lang, bufp, size, f);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
msg_release(msg);
@ -1926,6 +1924,7 @@ static void nr_paragraph(stream *out, message * m, faction * f)
char buf[4096], *bufp = buf;
size_t size = sizeof(buf) - 1;
assert(f);
bytes = (int)nr_render(m, f->locale, bufp, size, f);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();