From 7ec183b732d0354d167f545a90c9bd53383b32fa Mon Sep 17 00:00:00 2001 From: divverent Date: Fri, 26 Nov 2010 06:02:05 +0000 Subject: [PATCH] fix stdio mode git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10638 d7cf8633-e32d-0410-b094-e92efae38249 ::stable-branch::merge=25a89453e982d94fe580096eea01dfd46c51f890 --- crypto-keygen-standalone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto-keygen-standalone.c b/crypto-keygen-standalone.c index be60446a..66a8447d 100644 --- a/crypto-keygen-standalone.c +++ b/crypto-keygen-standalone.c @@ -98,7 +98,7 @@ void file2buf(const char *fn, char **data, size_t *datasize) *datasize = 0; size_t n = 0, dn = 0; if(!strncmp(fn, "/dev/fd/", 8)) - f = fdopen(atoi(fn + 8), "wb"); + f = fdopen(atoi(fn + 8), "rb"); else f = fopen(fn, "rb"); if(!f) @@ -111,6 +111,7 @@ void file2buf(const char *fn, char **data, size_t *datasize) if(!*data) { *datasize = 0; + fclose(f); return; } dn = fread(*data + n, 1, *datasize - n, f); -- 2.39.2