|
|
DescriptionFix an embedder test with leaked page object
The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete()
instead of FPDF_ClosePage() to free the new page. This led to a page object
leak in an embedder test. Correct the public API description
as well as its usage in the embedder test.
BUG=pdfium:242
Committed: https://pdfium.googlesource.com/pdfium/+/9b777deb00fb50dba37ccc1ee69767c6e04a3ee4
Patch Set 1 #
Total comments: 4
Patch Set 2 : address comments #Patch Set 3 : split CL #Patch Set 4 : tidy #
Messages
Total messages: 27 (18 generated)
The CQ bit was checked by weili@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Patchset #1 (id:1) has been deleted
The CQ bit was checked by weili@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
weili@chromium.org changed reviewers: + thestig@chromium.org, tsepez@chromium.org
pls review, thanks
https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fpdfedit_embedd... File fpdfsdk/fpdfedit_embeddertest.cpp (right): https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fpdfedit_embedd... fpdfsdk/fpdfedit_embeddertest.cpp:69: // FPDFPage_New() doesn't add any new page into document if the page index is This comment should be in a public/ header file. How does an embedder know if the page was in range and hence which function to use? Sounds like Delete() should be smarter and just handle all cases.
Ok, here's a proposal. In public/fpdf_edit.h, we add a comment to FPDFPage_New that the actual index of the page may not be the same as the argument, since it it limited to the current document length + 1. Then replace the comment "The page should be deleted with |FPDFPage_Delete| when finished." with the page should be closed with CPDF_ClosePage when finished as with any other page in the document. Then, I think the code above is right.
https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fsdk_baseform_e... File fpdfsdk/fsdk_baseform_embeddertest.cpp (right): https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fsdk_baseform_e... fpdfsdk/fsdk_baseform_embeddertest.cpp:45: CBA_AnnotIterator iter( I don't understand why these should change. UnderLying is an implementation detail and shouldn't be used in tests.
https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fsdk_baseform_e... File fpdfsdk/fsdk_baseform_embeddertest.cpp (right): https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fsdk_baseform_e... fpdfsdk/fsdk_baseform_embeddertest.cpp:45: CBA_AnnotIterator iter( On 2016/08/19 20:41:18, Tom Sepez wrote: > I don't understand why these should change. UnderLying is an implementation > detail and shouldn't be used in tests. Is this where the comment about ref-counts kicks in? If so, we should keep the result of getpageview in a local and release it later on,too.
Description was changed from ========== Fix embedder tests with leaked objects Both cases leak page objects. One needs to use proper function to delete the page, the other needs to unload the pages as well as using the method which doesn't increase the ref-count of the page. BUG=pdfium:242 ========== to ========== Fix an embedder test with leaked page object The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 ==========
Description was changed from ========== Fix an embedder test with leaked page object The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 ========== to ========== Fix an embedder test with leaked page object The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 ==========
thanks for all the suggestions. Split these two cases now for easier review and understanding. ptal, thanks https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fpdfedit_embedd... File fpdfsdk/fpdfedit_embeddertest.cpp (right): https://codereview.chromium.org/2260683003/diff/20001/fpdfsdk/fpdfedit_embedd... fpdfsdk/fpdfedit_embeddertest.cpp:69: // FPDFPage_New() doesn't add any new page into document if the page index is On 2016/08/19 20:24:48, Tom Sepez wrote: > This comment should be in a public/ header file. How does an embedder know if > the page was in range and hence which function to use? Sounds like Delete() > should be smarter and just handle all cases. Done.
The CQ bit was checked by weili@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
lgtm Perfect
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by weili@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Fix an embedder test with leaked page object The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 ========== to ========== Fix an embedder test with leaked page object The public API FPDFPage_New() incorrectly said to use FPDFPage_Delete() instead of FPDF_ClosePage() to free the new page. This led to a page object leak in an embedder test. Correct the public API description as well as its usage in the embedder test. BUG=pdfium:242 Committed: https://pdfium.googlesource.com/pdfium/+/9b777deb00fb50dba37ccc1ee69767c6e04a... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:70001) as https://pdfium.googlesource.com/pdfium/+/9b777deb00fb50dba37ccc1ee69767c6e04a... |