diff options
author | Hisham <hisham@gobolinux.org> | 2016-02-02 15:53:02 +0100 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-02-02 15:53:02 +0100 |
commit | b54d2dde407921caa7561dde6b45831ba93d0840 (patch) | |
tree | cd81eea35dd65e46d22f2801ea403e1efc06eb59 /linux/Platform.c | |
parent | a1f7f2869ec2bd860d5b4e4b39736ca877afdf6f (diff) |
Check for failure in allocations.
Diffstat (limited to 'linux/Platform.c')
-rw-r--r-- | linux/Platform.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/linux/Platform.c b/linux/Platform.c index 7b8a120b..04360ca3 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -220,16 +220,16 @@ char* Platform_getProcessEnv(pid_t pid) { char *env = NULL; if (fd) { size_t capacity = 4096, size = 0, bytes; - env = malloc(capacity); + env = xMalloc(capacity); while (env && (bytes = fread(env+size, 1, capacity-size, fd)) > 0) { size += bytes; capacity *= 2; - env = realloc(env, capacity); + env = xRealloc(env, capacity); } fclose(fd); if (size < 2 || env[size-1] || env[size-2]) { if (size + 2 < capacity) { - env = realloc(env, capacity+2); + env = xRealloc(env, capacity+2); } env[size] = 0; env[size+1] = 0; |