summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2017-09-08 18:29:42 +0200
committerAlbert Astals Cid <aacid@kde.org>2017-09-08 18:30:08 +0200
commit1316c7a41f4dd7276f404f775ebb5fef2d24ab1c (patch)
treec50ab3dfcf6b769b5b7fa8374ed27ac56338d2e7
parent2532df6060092e9fab7f041ae9598aff9cdd94bb (diff)
Annot: Fix crash on broken files
Bug #102607
-rw-r--r--poppler/Annot.cc42
1 files changed, 23 insertions, 19 deletions
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 17043044..87985675 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -6667,26 +6667,30 @@ AnnotRichMedia::Configuration::Configuration(Dict *dict)
} else if (!strcmp(name, "Video")) {
type = typeVideo;
} else {
- // determine from first instance
+ // determine from first non null instance
+ type = typeFlash; // default in case all instances are null
if (instances && nInstances > 0) {
- AnnotRichMedia::Instance *instance = instances[0];
- switch (instance->getType()) {
- case AnnotRichMedia::Instance::type3D:
- type = type3D;
- break;
- case AnnotRichMedia::Instance::typeFlash:
- type = typeFlash;
- break;
- case AnnotRichMedia::Instance::typeSound:
- type = typeSound;
- break;
- case AnnotRichMedia::Instance::typeVideo:
- type = typeVideo;
- break;
- default:
- type = typeFlash;
- break;
- }
+ for (int i = 0; i < nInstances; ++i) {
+ AnnotRichMedia::Instance *instance = instances[i];
+ if (instance) {
+ switch (instance->getType()) {
+ case AnnotRichMedia::Instance::type3D:
+ type = type3D;
+ break;
+ case AnnotRichMedia::Instance::typeFlash:
+ type = typeFlash;
+ break;
+ case AnnotRichMedia::Instance::typeSound:
+ type = typeSound;
+ break;
+ case AnnotRichMedia::Instance::typeVideo:
+ type = typeVideo;
+ break;
+ }
+ // break the loop since we found the first non null instance
+ break;
+ }
+ }
}
}
}