The public API functions ucal_getTZDataVersion (C) and getTZDataVersion (C++) both call into the function initTZDataVersion, which calls into ures_openDirect.
However, ures_openDirect will attempt to allocate memory for a number of things, one of which is the Resource Bundle. This can possibly fail (due to OOM), leading to the APIs returning a pointer to null.
If a stack allocated Resource Bundle could be used instead, then there would be one less thing that needs heap allocation in this code path.
Unfortunately, the internal function ures_openDirect does not take a Resource Bundle parameter, which means that it will always allocate.
We can add a similar internal API ures_openDirectFillIn which does take a Resource Bundle, and fills it in instead.
(This is similar to the ures_open and ures_openFillIn functions – one of which allocates and the other fills in an existing one).
The proposed internal API would look like this (in the file uresbund.cpp):