From 215fa4be9d1dbe96a97515665faedce14677956c Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Tue, 25 Nov 2008 12:53:21 +0000 Subject: [PATCH] - Check parameters before allocating memory - Patch by Daniel Zimmermann, - Fixes possible memory leaks pointed out by CID 605, bug #3910 svn path=/trunk/; revision=37628 --- reactos/lib/sdk/crt/time/strftime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/lib/sdk/crt/time/strftime.c b/reactos/lib/sdk/crt/time/strftime.c index c45ad2c52f8..6321928f66a 100644 --- a/reactos/lib/sdk/crt/time/strftime.c +++ b/reactos/lib/sdk/crt/time/strftime.c @@ -233,6 +233,8 @@ size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const struct char *x; char *f; size_t i,j; + if ((gsize = maxsize) < 1) + return 0; x = malloc(maxsize); j = wcslen(format); f = malloc(j+1); @@ -240,8 +242,6 @@ size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const struct f[i] = (char)*format; f[i] = 0; pt = x; - if ((gsize = maxsize) < 1) - return 0; if (_fmt(f, t)) { *pt = '\0'; free(f);