mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
fix Issue 23340 - std.path: expandTilde erroneously raises onOutOfMemory on failed getpwam_r()
This commit is contained in:
parent
92a9d600d1
commit
d51e3f99a3
1 changed files with 18 additions and 5 deletions
23
std/path.d
23
std/path.d
|
@ -3967,7 +3967,7 @@ string expandTilde(string inputPath) @safe nothrow
|
||||||
version (Posix)
|
version (Posix)
|
||||||
{
|
{
|
||||||
import core.exception : onOutOfMemoryError;
|
import core.exception : onOutOfMemoryError;
|
||||||
import core.stdc.errno : errno, ERANGE;
|
import core.stdc.errno : errno, EBADF, ENOENT, EPERM, ERANGE, ESRCH;
|
||||||
import core.stdc.stdlib : malloc, free, realloc;
|
import core.stdc.stdlib : malloc, free, realloc;
|
||||||
|
|
||||||
/* Joins a path from a C string to the remainder of path.
|
/* Joins a path from a C string to the remainder of path.
|
||||||
|
@ -4073,7 +4073,7 @@ string expandTilde(string inputPath) @safe nothrow
|
||||||
char[] extra_memory;
|
char[] extra_memory;
|
||||||
|
|
||||||
passwd result;
|
passwd result;
|
||||||
while (1)
|
loop: while (1)
|
||||||
{
|
{
|
||||||
extra_memory.length += extra_memory_size;
|
extra_memory.length += extra_memory_size;
|
||||||
|
|
||||||
|
@ -4096,10 +4096,23 @@ string expandTilde(string inputPath) @safe nothrow
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errno != ERANGE &&
|
switch (errno)
|
||||||
|
{
|
||||||
|
case ERANGE:
|
||||||
// On BSD and OSX, errno can be left at 0 instead of set to ERANGE
|
// On BSD and OSX, errno can be left at 0 instead of set to ERANGE
|
||||||
errno != 0)
|
case 0:
|
||||||
onOutOfMemoryError();
|
break;
|
||||||
|
|
||||||
|
case ENOENT:
|
||||||
|
case ESRCH:
|
||||||
|
case EBADF:
|
||||||
|
case EPERM:
|
||||||
|
// The given name or uid was not found.
|
||||||
|
break loop;
|
||||||
|
|
||||||
|
default:
|
||||||
|
onOutOfMemoryError();
|
||||||
|
}
|
||||||
|
|
||||||
// extra_memory isn't large enough
|
// extra_memory isn't large enough
|
||||||
import core.checkedint : mulu;
|
import core.checkedint : mulu;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue