forked from github/server
fixing new coverity scan defects
167039 Dereference after null check 167038 Unchecked return value
This commit is contained in:
parent
0b226ba75e
commit
51c2df62ca
|
@ -1505,6 +1505,7 @@ int owner_change(const region * r)
|
||||||
bool is_mourning(const region * r, int in_turn)
|
bool is_mourning(const region * r, int in_turn)
|
||||||
{
|
{
|
||||||
int change = owner_change(r);
|
int change = owner_change(r);
|
||||||
return (change == in_turn - 1 && r->land->ownership->last_owner && r->land->ownership->owner
|
return (change == in_turn - 1 && r->land &&
|
||||||
&& r->land->ownership->last_owner != r->land->ownership->owner);
|
r->land->ownership->last_owner && r->land->ownership->owner &&
|
||||||
|
r->land->ownership->last_owner != r->land->ownership->owner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1584,7 +1584,9 @@ int display_cmd(unit * u, struct order *ord)
|
||||||
free(*s);
|
free(*s);
|
||||||
if (s2) {
|
if (s2) {
|
||||||
char * str = strdup(s2);
|
char * str = strdup(s2);
|
||||||
unicode_utf8_trim(str);
|
if (unicode_utf8_trim(str) != 0) {
|
||||||
|
log_info("trimming info: %s", s2);
|
||||||
|
}
|
||||||
if (strlen(str) >= DISPLAYSIZE) {
|
if (strlen(str) >= DISPLAYSIZE) {
|
||||||
str[DISPLAYSIZE-1] = 0;
|
str[DISPLAYSIZE-1] = 0;
|
||||||
}
|
}
|
||||||
|
@ -1626,7 +1628,9 @@ static int rename_cmd(unit * u, order * ord, char **s, const char *s2)
|
||||||
/* TODO: Validate to make sure people don't have illegal characters in
|
/* TODO: Validate to make sure people don't have illegal characters in
|
||||||
* names, phishing-style? () come to mind. */
|
* names, phishing-style? () come to mind. */
|
||||||
strlcpy(name, s2, sizeof(name));
|
strlcpy(name, s2, sizeof(name));
|
||||||
unicode_utf8_trim(name);
|
if (unicode_utf8_trim(name) != 0) {
|
||||||
|
log_info("trimming name: %s", s2);
|
||||||
|
}
|
||||||
|
|
||||||
free(*s);
|
free(*s);
|
||||||
*s = strdup(name);
|
*s = strdup(name);
|
||||||
|
|
Loading…
Reference in New Issue