Skip to content

Commit 418c7b6

Browse files
authored
Update proc_utils.c
1 parent af38b77 commit 418c7b6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/utils/proc_utils.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ char *read_cmdline_from_task(pid_t pid, size_t *out_size) { // reads the command
2121
}
2222
mm = get_task_mm(task);
2323
rcu_read_unlock();
24-
if (!mm)
24+
if (!mm) {
2525
return NULL;
26+
}
2627

2728
// lock the memory map
2829
down_read(&mm->mmap_lock);
@@ -45,8 +46,9 @@ char *read_cmdline_from_task(pid_t pid, size_t *out_size) { // reads the command
4546
}
4647

4748
buffer[size] = '\0'; // null-terminate
48-
if (out_size)
49+
if (out_size) {
4950
*out_size = size;
50-
return buffer;
51+
}
52+
return buffer; // memory will be freed by the calle
5153
}
5254

0 commit comments

Comments
 (0)