summaryrefslogtreecommitdiff
path: root/gs/base/gslibctx.c
diff options
context:
space:
mode:
authorRobin Watts <robin@peeves.(none)>2013-03-26 13:09:49 -0700
committerRobin Watts <robin@peeves.(none)>2013-03-26 13:10:47 -0700
commit7d2e030ab25d8b31af22f0532ef813b0ff70e361 (patch)
treee10d6d9ac321eff661d6fa1019704fd3c92055c8 /gs/base/gslibctx.c
parenta56fae81ef7f77b1ab6dadf38b1ea7539cfca0e4 (diff)
downloadghostpdl-7d2e030ab25d8b31af22f0532ef813b0ff70e361.tar.gz
Fix various memory squeezing errors.
Mostly these are unchecked allocations, but some are errors in the cleanup paths.
Diffstat (limited to 'gs/base/gslibctx.c')
-rw-r--r--gs/base/gslibctx.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gs/base/gslibctx.c b/gs/base/gslibctx.c
index e0bf25904..e3f1b063c 100644
--- a/gs/base/gslibctx.c
+++ b/gs/base/gslibctx.c
@@ -192,13 +192,17 @@ int errwrite_nomem(const char *str, int len)
int errwrite(const gs_memory_t *mem, const char *str, int len)
{
int code;
+ gs_lib_ctx_t *ctx;
if (len == 0)
return 0;
- if (mem->gs_lib_ctx->stderr_fn)
- return (*mem->gs_lib_ctx->stderr_fn)(mem->gs_lib_ctx->caller_handle, str, len);
-
- code = fwrite(str, 1, len, mem->gs_lib_ctx->fstderr);
- fflush(mem->gs_lib_ctx->fstderr);
+ ctx = mem->gs_lib_ctx;
+ if (ctx == NULL)
+ return 0;
+ if (ctx->stderr_fn)
+ return (*ctx->stderr_fn)(ctx->caller_handle, str, len);
+
+ code = fwrite(str, 1, len, ctx->fstderr);
+ fflush(ctx->fstderr);
return code;
}