diff options
author | shennetsind <shennetsind@users.noreply.github.com> | 2015-01-17 21:00:26 -0200 |
---|---|---|
committer | shennetsind <shennetsind@users.noreply.github.com> | 2015-01-17 21:00:26 -0200 |
commit | 9638e8e3730baea5b28670f8d38dbd417777c976 (patch) | |
tree | 09b347f4bdcef20893db0877c7f06e88d29b7bd1 /src | |
parent | a3c4d675ba19df385be5d1e3966c61de7186da57 (diff) | |
parent | 3bf50615cd8a85bec21d0dab1ecf39a26c0e104b (diff) | |
download | hercules-9638e8e3730baea5b28670f8d38dbd417777c976.tar.gz hercules-9638e8e3730baea5b28670f8d38dbd417777c976.tar.bz2 hercules-9638e8e3730baea5b28670f8d38dbd417777c976.tar.xz hercules-9638e8e3730baea5b28670f8d38dbd417777c976.zip |
Merge pull request #444 from 4144/coverity
some fixes for different issues
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 2 | ||||
-rw-r--r-- | src/char/geoip.c | 3 | ||||
-rw-r--r-- | src/common/mapindex.c | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/char/char.c b/src/char/char.c index 1d9d1d65c..f1bacbeb3 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1461,7 +1461,7 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f struct mmo_charstatus char_dat; int from_id = 0; - if( from > MAX_CHARS || to > MAX_CHARS || ( sd->char_slots && to > sd->char_slots ) || sd->found_char[from] <= 0 ) + if( from >= MAX_CHARS || to >= MAX_CHARS || ( sd->char_slots && to > sd->char_slots ) || sd->found_char[from] <= 0 ) return false; if( !chr->mmo_char_fromsql(sd->found_char[from], &char_dat, false) ) // Only the short data is needed. diff --git a/src/char/geoip.c b/src/char/geoip.c index 4fe03ab07..e5b77af1f 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -78,7 +78,7 @@ const char* geoip_getcountry(uint32 ipnum) if (x >= GEOIP_COUNTRY_BEGIN) { x = x-GEOIP_COUNTRY_BEGIN; - if( x > GEOIP_MAX_COUNTRIES ) + if( x >= GEOIP_MAX_COUNTRIES ) return geoip_countryname[0]; return geoip_countryname[x]; @@ -133,6 +133,7 @@ void geoip_init(void) fno = fileno(db); if (fstat(fno, &bufa) < 0) { ShowError("geoip_readdb: Error stating GeoIP.dat! Error %d\n", errno); + fclose(db); geoip->final(false); return; } diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 0d8a69726..79125e010 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -126,7 +126,7 @@ unsigned short mapindex_name2id(const char* name) { } const char* mapindex_id2name_sub(unsigned short id,const char *file, int line, const char *func) { - if (id > MAX_MAPINDEX || !mapindex_exists(id)) { + if (id >= MAX_MAPINDEX || !mapindex_exists(id)) { ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line); return mapindex->list[0].name; // dummy empty string so that the callee doesn't crash } |