Skip to content

Commit

Permalink
Fix memory leaks caused by unneeded strdup()
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo1003 committed Jun 11, 2019
1 parent b82fcc1 commit 2818e9e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/linux/InotifyEventLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ void InotifyEventLoop::work() {
}

if (isDirectoryEvent) {
inotifyService->createDirectory(event->wd, strdup(event->name));
inotifyService->createDirectory(event->wd, event->name);
} else {
inotifyService->create(event->wd, strdup(event->name));
inotifyService->create(event->wd, event->name);
}
};

Expand All @@ -49,7 +49,7 @@ void InotifyEventLoop::work() {
return;
}

inotifyService->modify(event->wd, strdup(event->name));
inotifyService->modify(event->wd, event->name);
};

auto remove = [&event, &isDirectoryRemoval, &inotifyService]() {
Expand All @@ -60,7 +60,7 @@ void InotifyEventLoop::work() {
if (isDirectoryRemoval) {
inotifyService->removeDirectory(event->wd);
} else {
inotifyService->remove(event->wd, strdup(event->name));
inotifyService->remove(event->wd, event->name);
}
};

Expand Down Expand Up @@ -133,7 +133,7 @@ void InotifyEventLoop::work() {

renameStart();
} else if (event->mask & (uint32_t)IN_MOVE_SELF) {
inotifyService->remove(event->wd, strdup(event->name));
inotifyService->remove(event->wd, event->name);
inotifyService->removeDirectory(event->wd);
}
} while((position += sizeof(struct inotify_event) + event->len) < bytesRead);
Expand Down

0 comments on commit 2818e9e

Please sign in to comment.