From bec027258431c1f6d32dafe9f49f57017ba380ff Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Tue, 20 May 2014 21:46:45 +0200 Subject: [PATCH] WMaker: fix dangerous code in file scanning for wAdvancedInputDialog (Coverity #50172) As pointer by Coverity, the function wstrappend may move the string in memory (because that's what realloc does if it can't expand the allocated buffer in-place), so it is important to use the returned address and not assume the old pointer is still valid. Signed-off-by: Christophe CURIS --- src/dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dialog.c b/src/dialog.c index 8eb01f1a..6b26aef8 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -275,7 +275,7 @@ ScanFiles(const char *dir, const char *prefix, unsigned acceptmask, unsigned dec de->d_name + prefixlen) == WANotFound) { suffix = wstrdup(de->d_name + prefixlen); if (sb.st_mode & S_IFDIR) - wstrappend(suffix,"/"); + suffix = wstrappend(suffix, "/"); WMAddToArray(result, suffix); } wfree(fullfilename);