- Check parameters before allocating memory

- Patch by Daniel Zimmermann, <netzimme AT aim DOT com>
- Fixes possible memory leaks pointed out by CID 605, bug #3910

svn path=/trunk/; revision=37628
This commit is contained in:
Gregor Schneider 2008-11-25 12:53:21 +00:00
parent f7f455d197
commit 215fa4be9d

View file

@ -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);