[poppler] Patch: New additions in FileSpec
Pino Toscano
pino at kde.org
Tue Apr 5 06:41:49 PDT 2011
Alle martedì 5 aprile 2011, srinivas adicherla ha scritto:
> +const char* getFileNameFromPath (const char *filePath) {
- { goes on a new line
- make the function static and remove its declaration from the .h
> +static GBool getFileSpecObject(XRef *xref, Stream *stream, const
> char* fileName, Object *obj) {
{ goes on a new line
> + Object fileSpec, obj1, obj2;
> + int length;
> +
> + fileSpec.initDict(xref);
> + fileSpec.dictSet("Type", obj1.initName("Filespec"));
> + fileSpec.dictSet("F", obj1.initString(new GooString(fileName)));
> +
> + GooString *name = new GooString(fileName);
a new GooString(fileName) is already created for the "F" key, so just
create it once, using it for "F" and passing it to
pdfDocEncodingToUTF16, do not deleting it
> + char *fileNameUTF16 = pdfDocEncodingToUTF16(name, &length);
> + fileSpec.dictSet("UF", obj1.initString(new
> GooString(fileNameUTF16, length)));
> +
> + delete(fileNameUTF16);
as I already said in a previous review:
| pdfDocEncodingToUTF16 returns a new char[], which you have to
| delete [], not free() (as also Carlos said)
there's a difference between delete and delete []
> +GBool createFilespec (XRef *xref, GooString *filePathA, Object *obj)
> {
- { goes on a new line
- proper naming, "FileSpec"
> + fseek(fs, 0, SEEK_END);
> + size = ftell(fs);
as I already said:
| you are missing any kind of check on the return values of the two, for
| example on i/o errors or simply because the passed file could be even
| shorter than 10 bytes
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20110405/c33c9e7a/attachment.pgp>
More information about the poppler
mailing list