On Sun, Feb 28, 2010 at 02:28:08PM +0100, Aurelien Jarno wrote:
> reopen 571754
> thanks
> 
> On Sun, Feb 28, 2010 at 01:21:11PM +0100, Klaus Ethgen wrote:
> > But however, lets modify the program slightly to be constructive:
> > ---
> > #define _XOPEN_SOURCE
> > #include <stdio.h>
> > #include <time.h>
> > #include <locale.h>
> > 
> > int main(int argc, char **argv)
> > {
> >    char time[255];
> >    struct tm tm;
> > 
> >    setlocale(LC_ALL, "de_DE");
> >    strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);
> > 
> >    strftime(time, sizeof(time), "%c", &tm);
> >    fprintf(stdout, "%s\n", time);
> > } // int main(int argc, char **argv...
> > ---
> > 
> > Now it should be ok for you too. (See, it is nearly the same than the
> > example in the man page!)
> > 
> 
> Thanks for this new example, I am now able to reproducible the problem,
> I have therefore reopened the bug.
> 

I am afraid the bug is again in your code. strftime() crashes because
tm.tm_zone point to a non allocated memory zone. Initializing the struct
tm with strptime() is not enough as it only update the structure, and it
doesn't update this field.

The correct way to do it is to add the following line before the call to
strptime():
    memset(&tm, 0, sizeof(tm));
Then it doesn't crash anymore.

Ok to close the bug?

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurel...@aurel32.net                 http://www.aurel32.net



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to