diff options
author | FWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544> | 2012-07-16 17:36:36 +0000 |
---|---|---|
committer | FWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544> | 2012-07-16 17:36:36 +0000 |
commit | bdef90f99176d98cba7653b9a9ed4fdce362d2b7 (patch) | |
tree | e463cbe7135788e6e3616e9eea169ca09194f06c | |
parent | 42256d7e65fb4eac2a6cb24b79bfd0896d0dbc19 (diff) | |
download | starshatter-bdef90f99176d98cba7653b9a9ed4fdce362d2b7.zip starshatter-bdef90f99176d98cba7653b9a9ed4fdce362d2b7.tar.gz starshatter-bdef90f99176d98cba7653b9a9ed4fdce362d2b7.tar.bz2 |
PVS Studio warning fix: Possible Array underrun
-rw-r--r-- | Magic2/ModelFileOBJ.cpp | 6 | ||||
-rw-r--r-- | Stars45/Sim.cpp | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/Magic2/ModelFileOBJ.cpp b/Magic2/ModelFileOBJ.cpp index ae7a2a0..e3e35de 100644 --- a/Magic2/ModelFileOBJ.cpp +++ b/Magic2/ModelFileOBJ.cpp @@ -320,8 +320,10 @@ ModelFileOBJ::Load(Model* m, double scale) strcpy(libpath, root_path);
strcat(libpath, libname);
int n = strlen(libpath);
- char* p = &libpath[n-1];
- while (isspace(*p)) *p-- = 0;
+ if (n > 0) {
+ char* p = &libpath[n-1];
+ while (isspace(*p)) *p-- = 0;
+ }
int nmatls = LoadMatls(libpath, model);
}
diff --git a/Stars45/Sim.cpp b/Stars45/Sim.cpp index f8bcc08..141a225 100644 --- a/Stars45/Sim.cpp +++ b/Stars45/Sim.cpp @@ -3233,9 +3233,11 @@ SimRegion::DestroyShip(Ship* ship) if (sim->netgame && respawn)
sim->netgame->Respawn(ship->GetObjID(), spawn);
- int n = strlen(ship_name);
- if (ship_name[n-2] == ' ' && isdigit(ship_name[n-1]))
- ship_name[n-2] = 0;
+ int n = strlen(ship_name);
+ if (n > 2) {
+ if (ship_name[n-2] == ' ' && isdigit(ship_name[n-1]))
+ ship_name[n-2] = 0;
+ }
Element* elem = sim->FindElement(ship_name);
if (elem)
|