From 793c32d5f1e7ae431d41006ac490d4303ed7f431 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sun, 28 Dec 2014 21:31:35 +0800 Subject: [PATCH] Event: Avoid illegal multiplication for memset Because "file_events" is "FileEvent" type and adding an integral value to this pointer automatically scales that value by the size. Signed-off-by: Haomai Wang --- src/msg/async/Event.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msg/async/Event.cc b/src/msg/async/Event.cc index 2aea4ba0303..94c2ed1baec 100644 --- a/src/msg/async/Event.cc +++ b/src/msg/async/Event.cc @@ -120,7 +120,7 @@ int EventCenter::create_file_event(int fd, int mask, EventCallbackRef ctxt) lderr(cct) << __func__ << " failed to realloc file_events" << cpp_strerror(errno) << dendl; return -errno; } - memset(file_events+sizeof(FileEvent)*nevent, 0, sizeof(FileEvent)*(new_size-nevent)); + memset(file_events+nevent, 0, sizeof(FileEvent)*(new_size-nevent)); file_events = new_events; nevent = new_size; }