From 3083e0ea80ca60c500455bf59c848dbcd8a9b489 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 8 Feb 2018 16:59:38 -0600 Subject: [PATCH] Work around false positive RESOURCE_LEAK in coverity scan Fixes defect number 7520322 --- src/common.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common.cpp b/src/common.cpp index 55a753399..4c88ca4fc 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -313,7 +313,10 @@ char *wcs2str(const wchar_t *in) { // Here we probably allocate a buffer probably much larger than necessary. char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1); assert(out); - return wcs2str_internal(in, out); + //Instead of returning the return value of wcs2str_internal, return `out` directly. + //This eliminates false warnings in coverity about resource leaks. + wcs2str_internal(in, out); + return out; } char *wcs2str(const wcstring &in) { return wcs2str(in.c_str()); }