From 0c659c161858cc9c6bd03c7b9b06e1dcf35075b5 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 15 Nov 2014 19:40:33 +0100 Subject: [PATCH] WINGs: removed unnecessary size checks in WMGetBrowserPaths The function is building strings from the directory names into an allocated buffer, but the function took time first to calculate the exact size needed for the resulting string, so the check on wstrlcat's result will never fail. As we still use wstrlcat it is not possible to overrun the buffer, we would just return a truncated string in the list instead of return no list at all but the case where it would happen is impossible. This should fix Coverity #50111 (Resource leak) which was present in the code of one of the related early return. Signed-off-by: Christophe CURIS Signed-off-by: Carlos R. Mafra --- WINGs/wbrowser.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/WINGs/wbrowser.c b/WINGs/wbrowser.c index 4027c2e6..04756113 100644 --- a/WINGs/wbrowser.c +++ b/WINGs/wbrowser.c @@ -781,11 +781,7 @@ WMArray *WMGetBrowserPaths(WMBrowser * bPtr) path = wmalloc(slen); /* ignore first `/' */ for (i = 0; i <= column; i++) { - if (wstrlcat(path, bPtr->pathSeparator, slen) >= slen) { - wfree(path); - WMFreeArray(paths); - return NULL; - } + wstrlcat(path, bPtr->pathSeparator, slen); if (i == column) { item = lastItem; } else { @@ -793,10 +789,7 @@ WMArray *WMGetBrowserPaths(WMBrowser * bPtr) } if (!item) break; - if (wstrlcat(path, item->text, slen) >= slen) { - wfree(path); - return NULL; - } + wstrlcat(path, item->text, slen); } WMAddToArray(paths, path); } -- 2.11.4.GIT