Skip to content

Commit

Permalink
Replace poison memset by memset_s to avoid compiler optimizing it out
Browse files Browse the repository at this point in the history
  • Loading branch information
Flole998 committed Feb 20, 2024
1 parent 771504e commit c7a63e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/input/mpegts/mpegts_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ mpegts_table_dispatch
void
mpegts_table_release_ ( mpegts_table_t *mt )
{
int mt_size = sizeof(*mt);
dvb_table_release((mpegts_psi_table_t *)mt);
tvhtrace(LS_MPEGTS, "table: mux %p free %s %02X/%02X (%d) pid %04X (%d)",
mt->mt_mux, mt->mt_name, mt->mt_table, mt->mt_mask, mt->mt_table,
Expand All @@ -127,7 +128,14 @@ mpegts_table_release_ ( mpegts_table_t *mt )
tprofile_done(&mt->mt_profile);
if (tvhtrace_enabled()) {
/* poison */
memset(mt, 0xa5, sizeof(*mt));
#ifdef __STDC_LIB_EXT1__
memset_s(mt, sizeof(*mt), 0xa5, sizeof(*mt));
#else
volatile unsigned char *p = (unsigned char*)mt;
while (mt_size--){
*p++ = 0xa5;
}
#endif
}
free(mt);
}
Expand Down
2 changes: 2 additions & 0 deletions src/tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef TVHEADEND_H
#define TVHEADEND_H

#define __STDC_WANT_LIB_EXT1__ 1

#include "build.h"

#include <stdlib.h>
Expand Down

0 comments on commit c7a63e7

Please sign in to comment.