mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-26 11:30:55 +08:00
Work around false positive RESOURCE_LEAK in coverity scan
Fixes defect number 7520322
This commit is contained in:
parent
82b7e6de69
commit
3083e0ea80
@ -313,7 +313,10 @@ char *wcs2str(const wchar_t *in) {
|
|||||||
// Here we probably allocate a buffer probably much larger than necessary.
|
// Here we probably allocate a buffer probably much larger than necessary.
|
||||||
char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1);
|
char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1);
|
||||||
assert(out);
|
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()); }
|
char *wcs2str(const wcstring &in) { return wcs2str(in.c_str()); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user