Skip to content

Commit

Permalink
Fix stringop-truncation warning some compilers raise. (#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rot127 authored Oct 23, 2024
1 parent 5026c2c commit 32519c0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,12 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, SStream *OS, MCIn
struct insn_mnem *tmp = handle->mnem_list;
while(tmp) {
if (tmp->insn.id == insn->id) {
char str[CS_MNEMONIC_SIZE];
char str[CS_MNEMONIC_SIZE] = { 0 };

if (!str_replace(str, insn->mnemonic, cs_insn_name((csh)handle, insn->id), tmp->insn.mnemonic)) {
// copy result to mnemonic
(void)strncpy(insn->mnemonic, str, sizeof(insn->mnemonic) - 1);
CS_ASSERT_RET(sizeof(insn->mnemonic) == sizeof(str));
(void)memcpy(insn->mnemonic, str, sizeof(insn->mnemonic));
insn->mnemonic[sizeof(insn->mnemonic) - 1] = '\0';
}

Expand Down

0 comments on commit 32519c0

Please sign in to comment.