summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf/xpdf/Function.cc
Unidiff
Diffstat (limited to 'noncore/unsupported/qpdf/xpdf/Function.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/xpdf/Function.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/noncore/unsupported/qpdf/xpdf/Function.cc b/noncore/unsupported/qpdf/xpdf/Function.cc
index 815cc89..ebf3718 100644
--- a/noncore/unsupported/qpdf/xpdf/Function.cc
+++ b/noncore/unsupported/qpdf/xpdf/Function.cc
@@ -1,11 +1,11 @@
1//======================================================================== 1//========================================================================
2// 2//
3// Function.cc 3// Function.cc
4// 4//
5// Copyright 2001 Derek B. Noonburg 5// Copyright 2001-2002 Glyph & Cog, LLC
6// 6//
7//======================================================================== 7//========================================================================
8 8
9#ifdef __GNUC__ 9#ifdef __GNUC__
10#pragma implementation 10#pragma implementation
11#endif 11#endif
@@ -412,33 +412,34 @@ void SampledFunction::transform(fouble *in, fouble *out) {
412ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) { 412ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) {
413 Object obj1, obj2; 413 Object obj1, obj2;
414 GBool hasN; 414 GBool hasN;
415 int i; 415 int i;
416 416
417 ok = gFalse; 417 ok = gFalse;
418 hasN = gFalse;
419 418
420 //----- initialize the generic stuff 419 //----- initialize the generic stuff
421 if (!init(dict)) { 420 if (!init(dict)) {
422 goto err1; 421 goto err1;
423 } 422 }
424 if (m != 1) { 423 if (m != 1) {
425 error(-1, "Exponential function with more than one input"); 424 error(-1, "Exponential function with more than one input");
426 goto err1; 425 goto err1;
427 } 426 }
427 hasN = hasRange;
428 428
429 //----- default values 429 //----- default values
430 for (i = 0; i < funcMaxOutputs; ++i) { 430 for (i = 0; i < funcMaxOutputs; ++i) {
431 c0[i] = 0; 431 c0[i] = 0;
432 c1[i] = 1; 432 c1[i] = 1;
433 } 433 }
434 434
435 //----- C0 435 //----- C0
436 if (dict->lookup("C0", &obj1)->isArray()) { 436 if (dict->lookup("C0", &obj1)->isArray()) {
437 if (!hasN) { 437 if (!hasN) {
438 n = obj1.arrayGetLength(); 438 n = obj1.arrayGetLength();
439 hasN = gTrue;
439 } else if (obj1.arrayGetLength() != n) { 440 } else if (obj1.arrayGetLength() != n) {
440 error(-1, "Function's C0 array is wrong length"); 441 error(-1, "Function's C0 array is wrong length");
441 goto err2; 442 goto err2;
442 } 443 }
443 for (i = 0; i < n; ++i) { 444 for (i = 0; i < n; ++i) {
444 obj1.arrayGet(i, &obj2); 445 obj1.arrayGet(i, &obj2);
@@ -453,12 +454,13 @@ ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) {
453 obj1.free(); 454 obj1.free();
454 455
455 //----- C1 456 //----- C1
456 if (dict->lookup("C1", &obj1)->isArray()) { 457 if (dict->lookup("C1", &obj1)->isArray()) {
457 if (!hasN) { 458 if (!hasN) {
458 n = obj1.arrayGetLength(); 459 n = obj1.arrayGetLength();
460 hasN = gTrue;
459 } else if (obj1.arrayGetLength() != n) { 461 } else if (obj1.arrayGetLength() != n) {
460 error(-1, "Function's C1 array is wrong length"); 462 error(-1, "Function's C1 array is wrong length");
461 goto err2; 463 goto err2;
462 } 464 }
463 for (i = 0; i < n; ++i) { 465 for (i = 0; i < n; ++i) {
464 obj1.arrayGet(i, &obj2); 466 obj1.arrayGet(i, &obj2);
@@ -477,12 +479,19 @@ ExponentialFunction::ExponentialFunction(Object *funcObj, Dict *dict) {
477 error(-1, "Function has missing or invalid N"); 479 error(-1, "Function has missing or invalid N");
478 goto err2; 480 goto err2;
479 } 481 }
480 e = obj1.getNum(); 482 e = obj1.getNum();
481 obj1.free(); 483 obj1.free();
482 484
485 // this isn't supposed to happen, but I've run into (broken) PDF
486 // files where it does
487 if (!hasN) {
488 error(-1, "Exponential function does not define number of output values");
489 n = 1;
490 }
491
483 ok = gTrue; 492 ok = gTrue;
484 return; 493 return;
485 494
486 err3: 495 err3:
487 obj2.free(); 496 obj2.free();
488 err2: 497 err2: