[tracker] tracker-extract, pdf: Avoid possible NULL dereference
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-extract, pdf: Avoid possible NULL dereference
- Date: Mon, 12 Jul 2010 13:32:10 +0000 (UTC)
commit 6b1561ff4bd3c5690bbfbc712667269970ba8acc
Author: Aleksander Morgado <aleksander lanedo com>
Date: Mon Jul 12 15:31:58 2010 +0200
tracker-extract, pdf: Avoid possible NULL dereference
src/tracker-extract/tracker-extract-pdf.cpp | 88 +++++++++++++++------------
1 files changed, 50 insertions(+), 38 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-pdf.cpp b/src/tracker-extract/tracker-extract-pdf.cpp
index 6bd6ba3..908243e 100644
--- a/src/tracker-extract/tracker-extract-pdf.cpp
+++ b/src/tracker-extract/tracker-extract-pdf.cpp
@@ -121,73 +121,85 @@ read_toc (GooList *items,
switch (link_action->getKind()) {
case actionGoTo: {
- guint title_length = item->getTitleLength ();
LinkGoTo *gto = dynamic_cast <LinkGoTo *> (link_action);
- GooString *named_dest = gto->getNamedDest ();
- if (title_length > 0) {
- gchar *str = unicode_to_char (item->getTitle(),
- title_length);
- g_string_append_printf (*toc, "%s ", str);
- g_free (str);
- }
+ if (gto) {
+ guint title_length = item->getTitleLength ();
+ GooString *named_dest = gto->getNamedDest ();
- if (named_dest)
- g_string_append_printf (*toc, "%s ", named_dest->getCString ());
+ if (title_length > 0) {
+ gchar *str = unicode_to_char (item->getTitle(),
+ title_length);
+ g_string_append_printf (*toc, "%s ", str);
+ g_free (str);
+ }
+
+ if (named_dest)
+ g_string_append_printf (*toc, "%s ", named_dest->getCString ());
+ }
break;
}
case actionLaunch: {
- guint title_length = item->getTitleLength ();
LinkLaunch *lan = dynamic_cast <LinkLaunch *> (link_action);
- GooString *filen, *param;
- filen = lan->getFileName();
- param = lan->getParams();
+ if (lan) {
+ guint title_length = item->getTitleLength ();
+ GooString *filen, *param;
- if (title_length > 0) {
- gchar *str = unicode_to_char (item->getTitle(),
- title_length);
- g_string_append_printf (*toc, "%s ", str);
- g_free (str);
- }
+ filen = lan->getFileName();
+ param = lan->getParams();
+
+ if (title_length > 0) {
+ gchar *str = unicode_to_char (item->getTitle(),
+ title_length);
+ g_string_append_printf (*toc, "%s ", str);
+ g_free (str);
+ }
- if (filen)
- g_string_append_printf (*toc, "%s ", filen->getCString ());
+ if (filen)
+ g_string_append_printf (*toc, "%s ", filen->getCString ());
- if (param)
- g_string_append_printf (*toc, "%s ", param->getCString ());
+ if (param)
+ g_string_append_printf (*toc, "%s ", param->getCString ());
+ }
break;
}
case actionURI: {
LinkURI *uri = dynamic_cast <LinkURI *> (link_action);
- GooString *muri;
- muri = uri->getURI();
+ if (uri) {
+ GooString *muri;
- if (muri)
- g_string_append_printf (*toc, "%s ", muri->getCString ());
+ muri = uri->getURI();
+
+ if (muri)
+ g_string_append_printf (*toc, "%s ", muri->getCString ());
+ }
break;
}
case actionNamed: {
- guint title_length = item->getTitleLength ();
LinkNamed *named = dynamic_cast <LinkNamed *> (link_action);
- GooString *named_dest = named->getName ();
- if (title_length > 0) {
- gchar *str = unicode_to_char (item->getTitle(),
- title_length);
- g_string_append_printf (*toc, "%s ", str);
- g_free (str);
- }
+ if (named) {
+ GooString *named_dest = named->getName ();
+ guint title_length = item->getTitleLength ();
+
+ if (title_length > 0) {
+ gchar *str = unicode_to_char (item->getTitle(),
+ title_length);
+ g_string_append_printf (*toc, "%s ", str);
+ g_free (str);
+ }
- if (named_dest)
- g_string_append_printf (*toc, "%s ", named_dest->getCString ());
+ if (named_dest)
+ g_string_append_printf (*toc, "%s ", named_dest->getCString ());
+ }
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]