diff --git a/src/XSync.c b/src/XSync.c index 61f8600..492e189 100644 --- a/src/XSync.c +++ b/src/XSync.c @@ -290,8 +290,9 @@ XSyncListSystemCounters(Display *dpy, int *n_counters_return) list = (XSyncSystemCounter *)Xmalloc( rep.nCounters * sizeof(XSyncSystemCounter)); replylen = rep.length << 2; - pWireSysCounter = (xSyncSystemCounter *) Xmalloc ((unsigned) replylen + 1); - /* +1 to leave room for last null-terminator */ + pWireSysCounter = (xSyncSystemCounter *) Xmalloc ((unsigned) replylen + + sizeof(XSyncCounter)); + /* added sizeof counter to leave room for last counter read-ahead */ if ((!list) || (!pWireSysCounter)) {