From b51a0187bf419c132c0f53efe7f8b521933ac436 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sat, 14 Nov 2009 19:12:09 +0000 Subject: [PATCH] Fix potential unfreed memory on shutdown This was SVN commit r7200. --- source/lib/sysdep/os/linux/dir_watch_fam.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/lib/sysdep/os/linux/dir_watch_fam.cpp b/source/lib/sysdep/os/linux/dir_watch_fam.cpp index c25db3b1f7..cbeb223001 100644 --- a/source/lib/sysdep/os/linux/dir_watch_fam.cpp +++ b/source/lib/sysdep/os/linux/dir_watch_fam.cpp @@ -27,9 +27,10 @@ #include +// FAMEvent is large (~4KB), so define a smaller structure to store events struct NotificationEvent { - char* filename; + std::string filename; void *userdata; FAMCodes code; }; @@ -101,7 +102,7 @@ static void fam_event_loop_process_events() } NotificationEvent ne; - ne.filename = strndup(e.filename, PATH_MAX); + ne.filename = e.filename; ne.userdata = e.userdata; ne.code = e.code; @@ -115,7 +116,7 @@ static void* fam_event_loop(void*) { int famfd = FAMCONNECTION_GETFD(&fc); - while (true) + while(true) { fd_set fdrset; FD_ZERO(&fdrset); @@ -140,7 +141,7 @@ static void* fam_event_loop(void*) else { // oops - debug_printf(L"select error %d", errno); // TODO: be sure debug_printf is threadsafe + debug_printf(L"select error %d", errno); return NULL; } } @@ -233,7 +234,6 @@ LibError dir_watch_Poll(DirWatchNotifications& notifications) DirWatch* dirWatch = (DirWatch*)polled_notifications[i].userdata; fs::wpath pathname = dirWatch->path/wstring_from_utf8(polled_notifications[i].filename); notifications.push_back(DirWatchNotification(pathname, type)); - free(polled_notifications[i].filename); } // nothing new; try again later