// return the original PID if the NSpid line is missing
int nspid = pid;
- size_t size;
+ size_t size = 0;
char *line = NULL;
- while (getline(&line, &size, status) != -1)
+ while (getline(&line, &size, status) != -1) {
if (strstr(line, "NSpid:") != NULL)
// PID namespaces can be nested -- last number is innermost PID
nspid = (int)strtol(strrchr(line, '\t'), NULL, 10);
+ }
free(line);
return nspid;
return -1;
char *line = NULL;
- size_t size;
+ size_t size = 0;
long long begin, len;
while (getline(&line, &size, file) != -1) {
char *cursor = line;