pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pdf-devel] pdf_date.c, DATE_EXTRACT_INT


From: Hardy Falk
Subject: [pdf-devel] pdf_date.c, DATE_EXTRACT_INT
Date: Mon, 19 Nov 2007 22:13:26 +0100
User-agent: KMail/1.9.5

Hi jemarch,
The macro  DATE_EXTRACT_INT( NUM_DIGITS) is still buggy:
> #define DATE_EXTRACT_INT(NUM_DIGITS,VAR)                 \
>   do                                                     \
>     {                                                    \
>       aux_str = (char *) xmalloc (NUM_DIGITS);           \
>       strncpy (aux_str, (string + pos), NUM_DIGITS);     \
>       aux_str[NUM_DIGITS] = '\0'; \
The allocated area is too small !
>       if (pdf_str2int (aux_str, VAR) == PDF_ERROR)       \
>         {                                                \
>           goto error;                                    \
>         }                                                \
>       pos = pos + NUM_DIGITS;                            \
>       free (aux_str);                                    \
>     }                                                    \
>   while (0)
Additionally, there is a memory leak in the error branch.
Can we use alloca() or even strdupa()?
Why is aux_str declared in the enclosing scope? 









reply via email to

[Prev in Thread] Current Thread [Next in Thread]