]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Fix GCC 11 warns: Matrix4x4_FromArrayDoubleD3D overread
authorbones_was_here <bones_was_here@xa.org.au>
Fri, 10 Jun 2022 03:24:09 +0000 (13:24 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 20 Sep 2022 18:10:10 +0000 (04:10 +1000)
Signed-off-by: bones_was_here <bones_was_here@xa.org.au>
matrixlib.c
matrixlib.h
model_brush.c

index dd6f3c6a348919f14b7620cf2a0ac1daea2e352e..2724ce6ad8878e10b2318b3a1ef49da56ce42b94 100644 (file)
@@ -1123,42 +1123,42 @@ void Matrix4x4_ToArrayDoubleD3D(const matrix4x4_t *in, double out[16])
 #endif
 }
 
-void Matrix4x4_FromArrayDoubleD3D (matrix4x4_t *out, const double in[16])
+void Matrix4x4_FromArrayDoubleD3D (matrix4x4_t *out, const double in[4][4])
 {
 #ifdef MATRIX4x4_OPENGLORIENTATION
-       out->m[0][0] = in[0];
-       out->m[1][0] = in[1];
-       out->m[2][0] = in[2];
-       out->m[3][0] = in[3];
-       out->m[0][1] = in[4];
-       out->m[1][1] = in[5];
-       out->m[2][1] = in[6];
-       out->m[3][1] = in[7];
-       out->m[0][2] = in[8];
-       out->m[1][2] = in[9];
-       out->m[2][2] = in[10];
-       out->m[3][2] = in[11];
-       out->m[0][3] = in[12];
-       out->m[1][3] = in[13];
-       out->m[2][3] = in[14];
-       out->m[3][3] = in[15];
+       out->m[0][0] = in[0][0];
+       out->m[1][0] = in[0][1];
+       out->m[2][0] = in[0][2];
+       out->m[3][0] = in[0][3];
+       out->m[0][1] = in[1][0];
+       out->m[1][1] = in[1][1];
+       out->m[2][1] = in[1][2];
+       out->m[3][1] = in[1][3];
+       out->m[0][2] = in[2][0];
+       out->m[1][2] = in[2][1];
+       out->m[2][2] = in[2][2];
+       out->m[3][2] = in[2][3];
+       out->m[0][3] = in[3][0];
+       out->m[1][3] = in[3][1];
+       out->m[2][3] = in[3][2];
+       out->m[3][3] = in[3][3];
 #else
-       out->m[0][0] = in[0];
-       out->m[0][1] = in[1];
-       out->m[0][2] = in[2];
-       out->m[0][3] = in[3];
-       out->m[1][0] = in[4];
-       out->m[1][1] = in[5];
-       out->m[1][2] = in[6];
-       out->m[1][3] = in[7];
-       out->m[2][0] = in[8];
-       out->m[2][1] = in[9];
-       out->m[2][2] = in[10];
-       out->m[2][3] = in[11];
-       out->m[3][0] = in[12];
-       out->m[3][1] = in[13];
-       out->m[3][2] = in[14];
-       out->m[3][3] = in[15];
+       out->m[0][0] = in[0][0];
+       out->m[0][1] = in[0][1];
+       out->m[0][2] = in[0][2];
+       out->m[0][3] = in[0][3];
+       out->m[1][0] = in[1][0];
+       out->m[1][1] = in[1][1];
+       out->m[1][2] = in[1][2];
+       out->m[1][3] = in[1][3];
+       out->m[2][0] = in[2][0];
+       out->m[2][1] = in[2][1];
+       out->m[2][2] = in[2][2];
+       out->m[2][3] = in[2][3];
+       out->m[3][0] = in[3][0];
+       out->m[3][1] = in[3][1];
+       out->m[3][2] = in[3][2];
+       out->m[3][3] = in[3][3];
 #endif
 }
 
index cf76252447e6104d3100f32fb611692558aea90a..f2e60e284060e3ed8be11f5979a4dd00c3bec4cc 100644 (file)
@@ -93,7 +93,7 @@ void Matrix4x4_FromArrayDoubleGL(matrix4x4_t *out, const double in[16]);
 // converts a matrix4x4 to a double[16] array in the Direct3D orientation
 void Matrix4x4_ToArrayDoubleD3D(const matrix4x4_t *in, double out[16]);
 // creates a matrix4x4 from a double[16] array in the Direct3D orientation
-void Matrix4x4_FromArrayDoubleD3D(matrix4x4_t *out, const double in[16]);
+void Matrix4x4_FromArrayDoubleD3D(matrix4x4_t *out, const double in[4][4]);
 
 // converts a matrix4x4 to a float[16] array in the OpenGL orientation
 void Matrix4x4_ToArrayFloatGL(const matrix4x4_t *in, float out[16]);
index 82eca27ce476872558c5c427ff1858d0582439f3..9b97b8014f1c937cb9367fb035c012a8c222835b 100644 (file)
@@ -6563,7 +6563,7 @@ static void Mod_Q3BSP_LoadLightGrid(lump_t *l)
                        lightgridmatrix[1][3] = -(loadmodel->brushq3.num_lightgrid_imins[1] - 0.5f) / texturesize[1];
                        lightgridmatrix[2][3] = -(loadmodel->brushq3.num_lightgrid_imins[2] - 1.5f) / texturesize[2];
                        lightgridmatrix[3][3] = 1;
-                       Matrix4x4_FromArrayDoubleD3D(&loadmodel->brushq3.lightgridworldtotexturematrix, lightgridmatrix[0]);
+                       Matrix4x4_FromArrayDoubleD3D(&loadmodel->brushq3.lightgridworldtotexturematrix, lightgridmatrix);
                        loadmodel->brushq3.lightgridtexture = R_LoadTexture3D(loadmodel->texturepool, "lightgrid", texturesize[0], texturesize[1], texturesize[2], texturergba, TEXTYPE_RGBA, TEXF_CLAMP, 0, NULL);
                        Mem_Free(texturergba);
                }