Skip to content

X*TextPropertyToTextList: handle OOM situation

Tobias Stoeckmann requested to merge (removed):oom into master

The X{mb,wc,utf8}TextPropertyToTextList family of functions returns the text properties in form of a list in given pointer "list_return".

If the allocation of list_return fails, the functions currently still return a value of 0 or higher, implying that conversion was successful.

The manual page states that XNoMemory is returned if insufficient memory is available for the list or its elements. Therefore I have adjusted the code to match the API description.

How to reproduce:

The easiest way is to modify alloc_list src/xlibi18n/lcPrTxt.c to always return NULL. Use a tool like cwm (calmwm) on OpenBSD and try to start it. It leads to a NULL pointer dereference because it trusts the return value of Xutf8TextPropertyToTextList.

A portable version of cwm exists:

Otherwise WebRTC in chromium and firefox might use the function as well when capturing the desktop. But cwm is easier to debug/reproduce. ;)

Merge request reports