aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Brooks <special@dereferenced.net>2011-01-03 21:36:09 -0700
committerNick Mathewson <nickm@torproject.org>2011-04-28 17:13:45 -0400
commit2dc9546eef6d748245d90b288f28ace1aa9b6f14 (patch)
tree2c981c37c122c382b5eece827b7bf3656615ca01
parent51e551d3837990b7c4491253a88bedd2513fe1de (diff)
downloadtor-2dc9546eef6d748245d90b288f28ace1aa9b6f14.tar
tor-2dc9546eef6d748245d90b288f28ace1aa9b6f14.tar.gz
Correct the logic from f14754fbd for tor_gmtime_r
-rw-r--r--src/common/compat.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 9b7c0b782..3644bd999 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2112,7 +2112,7 @@ tor_localtime_r(const time_t *timep, struct tm *result)
* Convert *<b>timep</b> to a struct tm in UTC, and store the value in
* *<b>result</b>. Return the result on success, or NULL on failure.
*/
-#ifndef HAVE_GMTIME_R
+#ifdef HAVE_GMTIME_R
struct tm *
tor_gmtime_r(const time_t *timep, struct tm *result)
{
@@ -2130,7 +2130,8 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
tor_assert(result);
tor_mutex_acquire(m);
r = gmtime(timep);
- memcpy(result, r, sizeof(struct tm));
+ if (r)
+ memcpy(result, r, sizeof(struct tm));
tor_mutex_release(m);
return correct_tm(0, timep, result, r);
}
@@ -2141,7 +2142,8 @@ tor_gmtime_r(const time_t *timep, struct tm *result)
struct tm *r;
tor_assert(result);
r = gmtime(timep);
- memcpy(result, r, sizeof(struct tm));
+ if (r)
+ memcpy(result, r, sizeof(struct tm));
return correct_tm(0, timep, result, r);
}
#endif