stat segment file descriptor leak
Close the mmap file descriptor at first opportunity.
@@ -141,16 +141,19 @@ stat_segment_connect_r (const char *socket_name, stat_client_main_t * sm)
if (fstat (mfd, &st) == -1)
{
+ close (mfd);
perror ("mmap fstat failed");
return -4;
}
if ((memaddr =
mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, mfd, 0)) == MAP_FAILED)
{
+ close (mfd);
perror ("mmap map failed");
return -5;
}
+ close (mfd);
sm->memory_size = st.st_size;
sm->shared_header = memaddr;
sm->directory_vector =
