pdf-devel
[Top][All Lists]
Advanced

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

Re: [pdf-devel] pdf-fsys-disk.c: fpos_t VS size_t


From: Aleksander Morgado
Subject: Re: [pdf-devel] pdf-fsys-disk.c: fpos_t VS size_t
Date: Wed, 31 Mar 2010 17:11:02 +0200

Hi,

> 
> I got abnormal output file with size bigger than 1.5 TB. Debugging found
> the reason is failure calls of fsetpos. 

That's a huge PDF file! :-)

> 
> pdf_status_t
> pdf_fsys_disk_file_set_pos (pdf_fsys_file_t file,
>                             pdf_size_t new_pos)
> {
>   if(file != NULL)
>     {
>       return
> ((fsetpos(((pdf_fsys_disk_file_t)file->data)->file_descriptor, \
>                        (fpos_t*)&new_pos) == 0) ?
> \
>               PDF_OK :
> \
>               __pdf_fsys_disk_get_status_from_errno(errno));
>     }
>   else
>     {
>       return PDF_EBADDATA;
>     }
> }


Quoting fsetpos() reference:
        The fsetpos() function sets the file position and state
        indicators for the stream pointed to by stream according to the
        value of the object pointed to by pos, which must be a value
        obtained from an earlier call to fgetpos() on the same stream.

So, it seems that casting a pdf_size_t to fpos_t is definitely not the
way to go.


> The definition of fpos_t is something like:
>  22 typedef struct
>  23 {
>  24   __off_t __pos;
>  25   __mbstate_t __state;
>  26 } _G_fpos_t;
>  27 typedef struct
>  28 {
>  29   __off64_t __pos;
>  30   __mbstate_t __state;
>  31 } _G_fpos64_t;
> 
> I'm not sure is it necessary to init __state member. I get a network
> problem to connect to google.com and google.cn just has been closed.:(
> Please check the code.
> 

Unfortunately, it seems that the fpos_t structure must not be modified
'manually'. It should be treated as an opaque struct. According to the
fsetpos() documentation, the fpos_t should have been previously acquired
with a fgetpos() call.

Created a FS task for this:
http://www.gnupdf.org/flyspray/index.php?do=details&task_id=114


Cheers,
-Aleksander





reply via email to

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