/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugins.d/plymouth.c

  • Committer: Teddy Hogeborn
  • Date: 2017-09-03 08:53:22 UTC
  • Revision ID: teddy@recompile.se-20170903085322-rgmiij4v273kuubb
Fix another memory leak in plymouth plugin

* plugins.d/plymouth.c (get_pid): Free any individual direntries, not
  just the direntry list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
      error_plus(0, errno, "scandir");
300
300
    }
301
301
    if(ret > 0){
302
 
      ret = sscanf(direntries[0]->d_name, "%" SCNuMAX, &proc_id);
303
 
      if(ret < 0){
304
 
        error_plus(0, errno, "sscanf");
 
302
      for(int i = ret-1; i >= 0; i--){
 
303
        if(proc_id == 0){
 
304
          ret = sscanf(direntries[i]->d_name, "%" SCNuMAX, &proc_id);
 
305
          if(ret < 0){
 
306
            error_plus(0, errno, "sscanf");
 
307
          }
 
308
        }
 
309
        free(direntries[i]);
305
310
      }
306
311
    }
307
312
    /* scandir might preallocate for this variable (man page unclear).