Fix leak of X window title.

Running 'viewer' on Linux with an ASan build produced LSan reports about
leaking textproperty.value. The documentation for
XStringListToTextProperty states that it is up to the user to free the
XTextProperty::value returned with XFree.

In addition, check the return value of XStringListToTextProperty for
failure.

Change-Id: I0db45d3d94f7c8126049c6a343b1aa121f9a7523
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/357597
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
Ben Wagner 2021-01-22 14:31:29 -05:00
parent 32b3089618
commit 056bd0dd98

View File

@ -368,8 +368,11 @@ bool Window_unix::handleEvent(const XEvent& event) {
void Window_unix::setTitle(const char* title) {
XTextProperty textproperty;
XStringListToTextProperty(const_cast<char**>(&title), 1, &textproperty);
if (!XStringListToTextProperty(const_cast<char**>(&title), 1, &textproperty)) {
return;
}
XSetWMName(fDisplay, fWindow, &textproperty);
XFree(textproperty.value);
}
void Window_unix::show() {