summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Magic2/ModelFileOBJ.cpp6
-rw-r--r--Stars45/Sim.cpp8
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)