The condition for raising onOutOfMemory is: ``` if (errno != ERANGE && // On BSD and OSX, errno can be left at 0 instead of set to ERANGE errno != 0) onOutOfMemoryError(); ``` The documentation of getpwam_r says any of the following errno codes could be set. --- ERRORS 0 or ENOENT or ESRCH or EBADF or EPERM or ... The given name or uid was not found. EINTR A signal was caught; see signal(7). EIO I/O error. EMFILE The per-process limit on the number of open file descriptors has been reached. ENFILE The system-wide limit on the total number of open files has been reached. ENOMEM Insufficient memory to allocate passwd structure. ERANGE Insufficient buffer space supplied. --- The first set of errors should be checked, which breaks the loop before raising an OOM Exception (ENOENT is not an OOM issue). Test that triggers failure. ``` assert(expandTilde("~Idontexist/hey") == "~Idontexist/hey"); ```
@ibuclaw created dlang/phobos pull request #8572 "fix Issue 23340 - std.path: expandTilde erroneously raises onOutOfMemory on failed getpwam_r()" fixing this issue: - fix Issue 23340 - std.path: expandTilde erroneously raises onOutOfMemory on failed getpwam_r() https://github.com/dlang/phobos/pull/8572
dlang/phobos pull request #8572 "fix Issue 23340 - std.path: expandTilde erroneously raises onOutOfMemory on failed getpwam_r()" was merged into master: - 73411fa4e675de2542bda1f6a53f5f9647c99eb0 by Iain Buclaw: fix Issue 23340 - std.path: expandTilde erroneously raises onOutOfMemory on failed getpwam_r() https://github.com/dlang/phobos/pull/8572