summaryrefslogtreecommitdiffstats
path: root/Python/pytime.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-03 14:25:45 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-09-03 14:25:45 (GMT)
commit29ee6745af8ace80cef04c18b232771e8b00acdb (patch)
tree6963fac8bde8dc3da8b60736dc7845449182f919 /Python/pytime.c
parentfbb215cb2411385783b9b347870c84f1041c2a1a (diff)
downloadcpython-29ee6745af8ace80cef04c18b232771e8b00acdb.zip
cpython-29ee6745af8ace80cef04c18b232771e8b00acdb.tar.gz
cpython-29ee6745af8ace80cef04c18b232771e8b00acdb.tar.bz2
Enhance _PyTime_AsTimespec()
Ensure that the tv_nsec field is set, even if the function fails with an overflow.
Diffstat (limited to 'Python/pytime.c')
-rw-r--r--Python/pytime.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/pytime.c b/Python/pytime.c
index 8166cec..cea3cf5 100644
--- a/Python/pytime.c
+++ b/Python/pytime.c
@@ -479,13 +479,13 @@ _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts)
secs -= 1;
}
ts->tv_sec = (time_t)secs;
+ assert(0 <= nsec && nsec < SEC_TO_NS);
+ ts->tv_nsec = nsec;
+
if ((_PyTime_t)ts->tv_sec != secs) {
_PyTime_overflow();
return -1;
}
- ts->tv_nsec = nsec;
-
- assert(0 <= ts->tv_nsec && ts->tv_nsec < SEC_TO_NS);
return 0;
}
#endif