Commit 82f77cc1 authored by Jeff Zaroyko's avatar Jeff Zaroyko Committed by Alexandre Julliard

msvcrt: Avoid a NULL pointer deref in ctime.

parent b77f0a16
......@@ -31,6 +31,13 @@
#define MINSPERHOUR 60
#define HOURSPERDAY 24
static void test_ctime(void)
{
time_t badtime = -1;
char* ret;
ret = ctime(&badtime);
ok(ret == NULL, "expected ctime to return NULL, got %s\n", ret);
}
static void test_gmtime(void)
{
time_t gmt = (time_t)NULL;
......@@ -249,6 +256,7 @@ static void test_wstrtime(void)
START_TEST(time)
{
test_ctime();
test_gmtime();
test_mktime();
test_localtime();
......
......@@ -447,7 +447,10 @@ MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm)
*/
char * CDECL MSVCRT_ctime(const MSVCRT_time_t *time)
{
return MSVCRT_asctime( MSVCRT_localtime(time) );
struct MSVCRT_tm *t;
t = MSVCRT_localtime( time );
if (!t) return NULL;
return MSVCRT_asctime( t );
}
/*********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment