Skip to content

CurieTime.cpp: check gmtime() return pointer for NULL-ness #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions libraries/CurieTime/src/CurieTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int year(unsigned long t)
{
struct tm* tm = tTm(t);

return (tm->tm_year + YEAR_OFFSET);
return (tm) ? (tm->tm_year + YEAR_OFFSET) : -1;
}

int month()
Expand All @@ -64,7 +64,7 @@ int month(unsigned long t)
{
struct tm* tm = tTm(t);

return (tm->tm_mon + MONTH_OFFSET);
return (tm) ? (tm->tm_mon + MONTH_OFFSET) : -1;
}

int day()
Expand All @@ -78,7 +78,7 @@ int day(unsigned long t)
{
struct tm* tm = tTm(t);

return tm->tm_mday;
return (tm) ? tm->tm_mday : -1;
}

int hour()
Expand All @@ -92,7 +92,7 @@ int hour(unsigned long t)
{
struct tm* tm = tTm(t);

return tm->tm_hour;
return (tm) ? tm->tm_hour : -1;
}

int minute()
Expand All @@ -106,7 +106,7 @@ int minute(unsigned long t)
{
struct tm* tm = tTm(t);

return tm->tm_min;
return (tm) ? tm->tm_min : -1;
}

int second()
Expand All @@ -120,7 +120,7 @@ int second(unsigned long t)
{
struct tm* tm = tTm(t);

return tm->tm_sec;
return (tm) ? tm->tm_sec : -1;
}

void setTime(unsigned long t)
Expand Down