]> git.saurik.com Git - apt.git/commitdiff
dpkgpm: Convert users of localtime() to localtime_r()
authorJulian Andres Klode <jak@debian.org>
Fri, 23 Oct 2015 18:36:03 +0000 (20:36 +0200)
committerJulian Andres Klode <jak@debian.org>
Fri, 30 Oct 2015 14:35:13 +0000 (15:35 +0100)
The former is not thread-safe, whereas the latter is.

Gbp-Dch: ignore

apt-pkg/deb/dpkgpm.cc

index 5c77100366fa0944d9725a19867fa608192d8464..7a02533838fa0fb3bb82ecf56fc50b1e77d4bfcd 100644 (file)
@@ -840,7 +840,8 @@ bool pkgDPkgPM::OpenLog()
    // get current time
    char timestr[200];
    time_t const t = time(NULL);
-   struct tm const * const tmp = localtime(&t);
+   struct tm tm_buf;
+   struct tm const * const tmp = localtime_r(&t, &tm_buf);
    strftime(timestr, sizeof(timestr), "%F  %T", tmp);
 
    // open terminal log
@@ -927,7 +928,8 @@ bool pkgDPkgPM::CloseLog()
 {
    char timestr[200];
    time_t t = time(NULL);
-   struct tm *tmp = localtime(&t);
+   struct tm tm_buf;
+   struct tm *tmp = localtime_r(&t, &tm_buf);
    strftime(timestr, sizeof(timestr), "%F  %T", tmp);
 
    if(d->term_out)