Skip to content

Commit cc45f9b

Browse files
fix potential memory leak when invalid line is skipped
1 parent a65c2f5 commit cc45f9b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

userspace/libscap/scap_fds.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
706706
if(token == NULL)
707707
{
708708
ASSERT(false);
709+
free(fdinfo);
709710
continue;
710711
}
711712

@@ -717,6 +718,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
717718
if(token == NULL)
718719
{
719720
ASSERT(false);
721+
free(fdinfo);
720722
continue;
721723
}
722724

@@ -725,6 +727,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
725727
if(token == NULL)
726728
{
727729
ASSERT(false);
730+
free(fdinfo);
728731
continue;
729732
}
730733

@@ -733,6 +736,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
733736
if(token == NULL)
734737
{
735738
ASSERT(false);
739+
free(fdinfo);
736740
continue;
737741
}
738742

@@ -741,6 +745,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
741745
if(token == NULL)
742746
{
743747
ASSERT(false);
748+
free(fdinfo);
744749
continue;
745750
}
746751

@@ -749,6 +754,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
749754
if(token == NULL)
750755
{
751756
ASSERT(false);
757+
free(fdinfo);
752758
continue;
753759
}
754760

@@ -757,6 +763,7 @@ int32_t scap_fd_read_unix_sockets_from_proc_fs(scap_t *handle, scap_fdinfo **soc
757763
if(token == NULL)
758764
{
759765
ASSERT(false);
766+
free(fdinfo);
760767
continue;
761768
}
762769

0 commit comments

Comments
 (0)