Skip to content

Commit 4311db5

Browse files
authored
[rmodels] Fix -Wstringop-truncation warning (#4096)
rmodels.c: In function ‘LoadBoneInfoGLTF.isra’: rmodels.c:4874:32: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] 4874 | if (node.name != NULL) strncpy(bones[i].name, node.name, sizeof(bones[i].name)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent f947f89 commit 4311db5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/rmodels.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -4871,7 +4871,11 @@ static BoneInfo *LoadBoneInfoGLTF(cgltf_skin skin, int *boneCount)
48714871
for (unsigned int i = 0; i < skin.joints_count; i++)
48724872
{
48734873
cgltf_node node = *skin.joints[i];
4874-
if (node.name != NULL) strncpy(bones[i].name, node.name, sizeof(bones[i].name));
4874+
if (node.name != NULL)
4875+
{
4876+
strncpy(bones[i].name, node.name, sizeof(bones[i].name));
4877+
bones[i].name[sizeof(bones[i].name) - 1] = '\0';
4878+
}
48754879

48764880
// Find parent bone index
48774881
unsigned int parentIndex = -1;

0 commit comments

Comments
 (0)