summaryrefslogtreecommitdiffhomepage
path: root/src/physac.h
diff options
context:
space:
mode:
authorJoão Coelho <[email protected]>2019-10-29 14:57:19 +0000
committerRay <[email protected]>2019-10-29 15:57:19 +0100
commit75b0264f35d8895c1e64c7c7bc85d1572d167cf2 (patch)
treed02dd8ce1f168e60c5f7e9551b9dca1101fdf51b /src/physac.h
parent64c588e9d8e9cb34da4fe592ae091d62f59d6853 (diff)
downloadraylib-75b0264f35d8895c1e64c7c7bc85d1572d167cf2.tar.gz
raylib-75b0264f35d8895c1e64c7c7bc85d1572d167cf2.zip
fix various problems, thanks CppCheck :) (#1005)
* explained a bit more the core_window_letterbox example * fixed a few 'ups' moments that could lead to mild head pain and time loss
Diffstat (limited to 'src/physac.h')
-rw-r--r--src/physac.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/physac.h b/src/physac.h
index 4119feae..b23fb1af 100644
--- a/src/physac.h
+++ b/src/physac.h
@@ -842,9 +842,17 @@ PHYSACDEF void DestroyPhysicsBody(PhysicsBody body)
}
}
- #if defined(PHYSAC_DEBUG)
- if (index == -1) printf("[PHYSAC] cannot find body id %i in pointers array\n", id);
- #endif
+
+ if (index == -1){
+
+ #if defined(PHYSAC_DEBUG)
+ printf("[PHYSAC] cannot find body id %i in pointers array\n", id);
+ #endif
+
+ // prevent access to index -1
+ return;
+ }
+
// Free body allocated memory
PHYSAC_FREE(body);
@@ -1249,9 +1257,16 @@ static void DestroyPhysicsManifold(PhysicsManifold manifold)
}
}
- #if defined(PHYSAC_DEBUG)
- if (index == -1) printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id);
- #endif
+
+ if (index == -1) {
+ #if defined(PHYSAC_DEBUG)
+ printf("[PHYSAC] cannot find manifold id %i in pointers array\n", id);
+ #endif
+
+ //prevent access to index -1
+ return;
+ }
+
// Free manifold allocated memory
PHYSAC_FREE(manifold);