[pdfmod] [PdfSharp] Fix crash if Catalog.Outlines is PdfNull (bgo#633123)
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pdfmod] [PdfSharp] Fix crash if Catalog.Outlines is PdfNull (bgo#633123)
- Date: Thu, 3 Mar 2011 18:17:09 +0000 (UTC)
commit 7e1ef2f2513bf31dcb613ce97b066595f00a1827
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu Mar 3 12:15:37 2011 -0600
[PdfSharp] Fix crash if Catalog.Outlines is PdfNull (bgo#633123)
lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs b/lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs
index f785f00..b55420b 100644
--- a/lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs
+++ b/lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs
@@ -147,10 +147,20 @@ namespace PdfSharp.Pdf.Advanced
{
if (this.outline == null) {
try {
- this.outline = (PdfOutline)Elements.GetValue(Keys.Outlines, VCF.CreateIndirect);
+ var obj = Elements.GetValue(Keys.Outlines, VCF.CreateIndirect);
+ this.outline = obj as PdfOutline;
+
+ // If there's a PdfNull object there (pdfopt does this) then remove it
+ // and replace it with a real PdfOutline so that the user can edit the outlines/bookmarks
+ // if they want to
+ if (this.outline == null && obj is PdfNull) {
+ Elements.Remove (Keys.Outlines);
+ this.outline = Elements.GetValue(Keys.Outlines, VCF.CreateIndirect) as PdfOutline;
+ }
} catch (InvalidOperationException) {
+ // This happens if the Outline iref points to a null value; remove it and start over
Elements.Remove (Keys.Outlines);
- this.outline = (PdfOutline)Elements.GetValue(Keys.Outlines, VCF.CreateIndirect);
+ this.outline = Elements.GetValue(Keys.Outlines, VCF.CreateIndirect) as PdfOutline;
}
}
return this.outline.Outlines;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]