Skip to content

Commit

Permalink
query_proc_modules_for_video(): initialize sscanf destination variables
Browse files Browse the repository at this point in the history
Per issue #354, if compiled with clang option -flto (Link Time
Optimization) a segfault occurs.  Initialize the variables as
suugested in that issue, though it's unclear why thiw works.
  • Loading branch information
rockowitz committed Jan 23, 2024
1 parent a3ad616 commit 5f9d97f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app_sysenv/query_sysenv_procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ int query_proc_modules_for_video() {
int ndx = 0;
for (ndx=0; ndx<garray->len; ndx++) {
char * curline = g_ptr_array_index(garray, ndx);
char mod_name[32];
// Per Issue 354, user encountered segfault if built with
// -flto (Link Time Optimization). For an unclear reason,
// initializing the destination string variables solves the problem.
char mod_name[32] = {};
int mod_size;
int mod_instance_ct;
char mod_dependencies[500];
char mod_load_state[10]; // one of: Live Loading Unloading
char mod_addr[30];
char mod_dependencies[500] = {};
char mod_load_state[10] = {}; // one of: Live Loading Unloading
char mod_addr[30] = {};
int piece_ct = sscanf(curline, "%s %d %d %s %s %s",
mod_name,
&mod_size,
Expand Down

0 comments on commit 5f9d97f

Please sign in to comment.