Main GraphicsMagick source repository
Revisão | dc28ec43d4838d209ecf06bb1bde099820b0efec (tree) |
---|---|
Hora | 2021-07-18 23:58:45 |
Autor | Bob Friesenhahn <bfriesen@Grap...> |
Commiter | Bob Friesenhahn |
MSL: Add more input image validations and use macros to reduce repeated code.
@@ -1,3 +1,14 @@ | ||
1 | +2021-07-18 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> | |
2 | + | |
3 | + * coders/msl.c (MSLStartElement): Use macros to simplify | |
4 | + validations and reduce repeated code fragments. Add validations | |
5 | + for image size and pixels present where applicable. Fixes | |
6 | + oss-fuzz 36224 "graphicsmagick:coder_MSL_fuzzer: Timeout in | |
7 | + coder_MSL_fuzzer". | |
8 | + | |
9 | + * magick/transform.c (RollImage): Assert that image rows and | |
10 | + columns are not zero. | |
11 | + | |
1 | 12 | 2021-07-16 Bob Friesenhahn <bfriesen@simple.dallas.tx.us> |
2 | 13 | |
3 | 14 | * coders/jp2.c (initialize_jasper): Update for the latest version |
@@ -10,5 +10,5 @@ | ||
10 | 10 | |
11 | 11 | #define public MagickPackageName "GraphicsMagick" |
12 | 12 | #define public MagickPackageVersion "1.4" |
13 | -#define public MagickPackageVersionAddendum ".020210716" | |
14 | -#define public MagickPackageReleaseDate "snapshot-20210716" | |
13 | +#define public MagickPackageVersionAddendum ".020210718" | |
14 | +#define public MagickPackageReleaseDate "snapshot-20210718" |
@@ -580,6 +580,36 @@ | ||
580 | 580 | } |
581 | 581 | } |
582 | 582 | |
583 | +#define MSL_BREAK_IF_IMAGE_NULL(_image) \ | |
584 | + if (_image == (Image *) NULL) \ | |
585 | + { \ | |
586 | + ThrowException(msl_info->exception,OptionError, \ | |
587 | + NoImagesDefined,(char *) name); \ | |
588 | + break; \ | |
589 | + } | |
590 | + | |
591 | +#define MSL_BREAK_IF_IMAGE_ZERO_SIZE(_image) \ | |
592 | + if ((_image->rows) == 0 || \ | |
593 | + (_image->columns == 0)) \ | |
594 | + { \ | |
595 | + ThrowException(msl_info->exception,OptionError, \ | |
596 | + NonzeroWidthAndHeightRequired,(char *) name); \ | |
597 | + break; \ | |
598 | + } | |
599 | + | |
600 | +#define MSL_BREAK_IF_IMAGE_PIXEL_CACHE_NOT_PRESENT(_image) \ | |
601 | + if (!GetPixelCachePresent(_image)) \ | |
602 | + { \ | |
603 | + ThrowException(msl_info->exception,OptionError, \ | |
604 | + NoImagesDefined,(char *) name); \ | |
605 | + break; \ | |
606 | + } | |
607 | + | |
608 | +#define MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(_image) \ | |
609 | + MSL_BREAK_IF_IMAGE_NULL(_image); \ | |
610 | + MSL_BREAK_IF_IMAGE_ZERO_SIZE(_image); \ | |
611 | + MSL_BREAK_IF_IMAGE_PIXEL_CACHE_NOT_PRESENT(_image) | |
612 | + | |
583 | 613 | static void |
584 | 614 | MSLStartElement(void *context,const xmlChar *name, |
585 | 615 | const xmlChar **attributes) |
@@ -628,23 +658,14 @@ | ||
628 | 658 | double radius = 0.0, |
629 | 659 | sigma = 1.0; |
630 | 660 | |
631 | - if (msl_info->image[n] == (Image *) NULL) | |
632 | - { | |
633 | - ThrowException(msl_info->exception,OptionError,NoImagesDefined, | |
634 | - (char *) name); | |
635 | - break; | |
636 | - } | |
661 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
662 | + | |
637 | 663 | if (attributes != (const xmlChar **) NULL) |
638 | 664 | { |
639 | 665 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
640 | 666 | { |
641 | 667 | keyword=(const char *) attributes[i++]; |
642 | - if (msl_info->attributes[n] == (Image *) NULL) | |
643 | - { | |
644 | - ThrowException(msl_info->exception,OptionError, | |
645 | - NoImagesDefined,(char *) keyword); | |
646 | - break; | |
647 | - } | |
668 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
648 | 669 | value=TranslateText(msl_info->image_info[n], |
649 | 670 | msl_info->attributes[n], |
650 | 671 | (char *) attributes[i]); |
@@ -711,23 +732,14 @@ | ||
711 | 732 | width = height = 6; /* this is the value that Magick++ uses */ |
712 | 733 | x = y = 0; |
713 | 734 | |
714 | - if (msl_info->image[n] == (Image *) NULL) | |
715 | - { | |
716 | - ThrowException(msl_info->exception,OptionError,NoImagesDefined, | |
717 | - (char *) name); | |
718 | - break; | |
719 | - } | |
735 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
736 | + | |
720 | 737 | if (attributes != (const xmlChar **) NULL) |
721 | 738 | { |
722 | 739 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
723 | 740 | { |
724 | 741 | keyword=(const char *) attributes[i++]; |
725 | - if (msl_info->attributes[n] == (Image *) NULL) | |
726 | - { | |
727 | - ThrowException(msl_info->exception,OptionError, | |
728 | - NoImagesDefined,(char *) keyword); | |
729 | - break; | |
730 | - } | |
742 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
731 | 743 | value=TranslateText(msl_info->image_info[n], |
732 | 744 | msl_info->attributes[n], |
733 | 745 | (char *) attributes[i]); |
@@ -836,23 +848,14 @@ | ||
836 | 848 | double radius = 0.0, |
837 | 849 | sigma = 1.0; |
838 | 850 | |
839 | - if (msl_info->image[n] == (Image *) NULL) | |
840 | - { | |
841 | - ThrowException(msl_info->exception,OptionError, | |
842 | - NoImagesDefined,(char *) name); | |
843 | - break; | |
844 | - } | |
851 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
852 | + | |
845 | 853 | if (attributes != (const xmlChar **) NULL) |
846 | 854 | { |
847 | 855 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
848 | 856 | { |
849 | 857 | keyword=(const char *) attributes[i++]; |
850 | - if (msl_info->attributes[n] == (Image *) NULL) | |
851 | - { | |
852 | - ThrowException(msl_info->exception,OptionError, | |
853 | - NoImagesDefined,(char *) keyword); | |
854 | - break; | |
855 | - } | |
858 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
856 | 859 | value=TranslateText(msl_info->image_info[n], |
857 | 860 | msl_info->attributes[n], |
858 | 861 | (char *) attributes[i]); |
@@ -920,23 +923,14 @@ | ||
920 | 923 | height=msl_info->image[n]->rows; |
921 | 924 | x = y = 0; |
922 | 925 | |
923 | - if (msl_info->image[n] == (Image *) NULL) | |
924 | - { | |
925 | - ThrowException(msl_info->exception,OptionError, | |
926 | - NoImagesDefined,(char *) name); | |
927 | - break; | |
928 | - } | |
926 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
927 | + | |
929 | 928 | if (attributes == (const xmlChar **) NULL) |
930 | 929 | break; |
931 | 930 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
932 | 931 | { |
933 | 932 | keyword=(const char *) attributes[i++]; |
934 | - if (msl_info->attributes[n] == (Image *) NULL) | |
935 | - { | |
936 | - ThrowException(msl_info->exception,OptionError, | |
937 | - NoImagesDefined,(char *) keyword); | |
938 | - break; | |
939 | - } | |
933 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
940 | 934 | value=TranslateText(msl_info->image_info[n], |
941 | 935 | msl_info->attributes[n], |
942 | 936 | (char *) attributes[i]); |
@@ -1051,23 +1045,14 @@ | ||
1051 | 1045 | |
1052 | 1046 | x = y = 0; |
1053 | 1047 | |
1054 | - if (msl_info->image[n] == (Image *) NULL) | |
1055 | - { | |
1056 | - ThrowException(msl_info->exception,OptionError, | |
1057 | - NoImagesDefined,(char *) name); | |
1058 | - break; | |
1059 | - } | |
1048 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1049 | + | |
1060 | 1050 | if (attributes == (const xmlChar **) NULL) |
1061 | 1051 | break; |
1062 | 1052 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
1063 | 1053 | { |
1064 | 1054 | keyword=(const char *) attributes[i++]; |
1065 | - if (msl_info->attributes[n] == (Image *) NULL) | |
1066 | - { | |
1067 | - ThrowException(msl_info->exception,OptionError, | |
1068 | - NoImagesDefined,(char *) keyword); | |
1069 | - break; | |
1070 | - } | |
1055 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
1071 | 1056 | value=TranslateText(msl_info->image_info[n], |
1072 | 1057 | msl_info->attributes[n], |
1073 | 1058 | (char *) attributes[i]); |
@@ -1259,28 +1244,19 @@ | ||
1259 | 1244 | } |
1260 | 1245 | else if (LocaleCompare((char *) name,"crop") == 0) |
1261 | 1246 | { |
1247 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1248 | + | |
1262 | 1249 | /* init the values */ |
1263 | 1250 | width=msl_info->image[n]->columns; |
1264 | 1251 | height=msl_info->image[n]->rows; |
1265 | 1252 | x = y = 0; |
1266 | 1253 | |
1267 | - if (msl_info->image[n] == (Image *) NULL) | |
1268 | - { | |
1269 | - ThrowException(msl_info->exception,OptionError, | |
1270 | - NoImagesDefined,(char *) name); | |
1271 | - break; | |
1272 | - } | |
1273 | 1254 | if (attributes == (const xmlChar **) NULL) |
1274 | 1255 | break; |
1275 | 1256 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
1276 | 1257 | { |
1277 | 1258 | keyword=(const char *) attributes[i++]; |
1278 | - if (msl_info->attributes[n] == (Image *) NULL) | |
1279 | - { | |
1280 | - ThrowException(msl_info->exception,OptionError, | |
1281 | - NoImagesDefined,(char *) keyword); | |
1282 | - break; | |
1283 | - } | |
1259 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
1284 | 1260 | value=TranslateText(msl_info->image_info[n], |
1285 | 1261 | msl_info->attributes[n], |
1286 | 1262 | (char *) attributes[i]); |
@@ -1393,12 +1369,7 @@ | ||
1393 | 1369 | { |
1394 | 1370 | if (LocaleCompare((char *) name, "despeckle") == 0) |
1395 | 1371 | { |
1396 | - if (msl_info->image[n] == (Image *) NULL) | |
1397 | - { | |
1398 | - ThrowException(msl_info->exception,OptionError, | |
1399 | - NoImagesDefined,(char *) name); | |
1400 | - break; | |
1401 | - } | |
1372 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1402 | 1373 | |
1403 | 1374 | /* no attributes here */ |
1404 | 1375 |
@@ -1427,23 +1398,14 @@ | ||
1427 | 1398 | { |
1428 | 1399 | double radius = 0.0; |
1429 | 1400 | |
1430 | - if (msl_info->image[n] == (Image *) NULL) | |
1431 | - { | |
1432 | - ThrowException(msl_info->exception,OptionError, | |
1433 | - NoImagesDefined,(char *) name); | |
1434 | - break; | |
1435 | - } | |
1401 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1402 | + | |
1436 | 1403 | if (attributes != (const xmlChar **) NULL) |
1437 | 1404 | { |
1438 | 1405 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
1439 | 1406 | { |
1440 | 1407 | keyword=(const char *) attributes[i++]; |
1441 | - if (msl_info->attributes[n] == (Image *) NULL) | |
1442 | - { | |
1443 | - ThrowException(msl_info->exception,OptionError, | |
1444 | - NoImagesDefined,(char *) keyword); | |
1445 | - break; | |
1446 | - } | |
1408 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
1447 | 1409 | value=TranslateText(msl_info->image_info[n], |
1448 | 1410 | msl_info->attributes[n], |
1449 | 1411 | (char *) attributes[i]); |
@@ -1497,23 +1459,14 @@ | ||
1497 | 1459 | double radius = 0.0, |
1498 | 1460 | sigma = 1.0; |
1499 | 1461 | |
1500 | - if (msl_info->image[n] == (Image *) NULL) | |
1501 | - { | |
1502 | - ThrowException(msl_info->exception,OptionError, | |
1503 | - NoImagesDefined,(char *) name); | |
1504 | - break; | |
1505 | - } | |
1462 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1463 | + | |
1506 | 1464 | if (attributes != (const xmlChar **) NULL) |
1507 | 1465 | { |
1508 | 1466 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
1509 | 1467 | { |
1510 | 1468 | keyword=(const char *) attributes[i++]; |
1511 | - if (msl_info->attributes[n] == (Image *) NULL) | |
1512 | - { | |
1513 | - ThrowException(msl_info->exception,OptionError, | |
1514 | - NoImagesDefined,(char *) keyword); | |
1515 | - break; | |
1516 | - } | |
1469 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
1517 | 1470 | value=TranslateText(msl_info->image_info[n], |
1518 | 1471 | msl_info->attributes[n], |
1519 | 1472 | (char *) attributes[i]); |
@@ -1576,12 +1529,7 @@ | ||
1576 | 1529 | } |
1577 | 1530 | else if (LocaleCompare((char *) name, "enhance") == 0) |
1578 | 1531 | { |
1579 | - if (msl_info->image[n] == (Image *) NULL) | |
1580 | - { | |
1581 | - ThrowException(msl_info->exception,OptionError, | |
1582 | - NoImagesDefined,(char *) name); | |
1583 | - break; | |
1584 | - } | |
1532 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1585 | 1533 | |
1586 | 1534 | /* no attributes here */ |
1587 | 1535 |
@@ -1627,12 +1575,7 @@ | ||
1627 | 1575 | { |
1628 | 1576 | if (LocaleCompare((char *) name, "flatten") == 0) |
1629 | 1577 | { |
1630 | - if (msl_info->image[n] == (Image *) NULL) | |
1631 | - { | |
1632 | - ThrowException(msl_info->exception,OptionError, | |
1633 | - NoImagesDefined,(char *) name); | |
1634 | - break; | |
1635 | - } | |
1578 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1636 | 1579 | |
1637 | 1580 | /* no attributes here */ |
1638 | 1581 |
@@ -1652,12 +1595,7 @@ | ||
1652 | 1595 | } |
1653 | 1596 | else if (LocaleCompare((char *) name, "flip") == 0) |
1654 | 1597 | { |
1655 | - if (msl_info->image[n] == (Image *) NULL) | |
1656 | - { | |
1657 | - ThrowException(msl_info->exception,OptionError, | |
1658 | - NoImagesDefined,(char *) name); | |
1659 | - break; | |
1660 | - } | |
1598 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1661 | 1599 | |
1662 | 1600 | /* no attributes here */ |
1663 | 1601 |
@@ -1677,12 +1615,7 @@ | ||
1677 | 1615 | } |
1678 | 1616 | else if (LocaleCompare((char *) name, "flop") == 0) |
1679 | 1617 | { |
1680 | - if (msl_info->image[n] == (Image *) NULL) | |
1681 | - { | |
1682 | - ThrowException(msl_info->exception,OptionError, | |
1683 | - NoImagesDefined,(char *) name); | |
1684 | - break; | |
1685 | - } | |
1618 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1686 | 1619 | |
1687 | 1620 | /* no attributes here */ |
1688 | 1621 |
@@ -1702,27 +1635,18 @@ | ||
1702 | 1635 | } |
1703 | 1636 | else if (LocaleCompare((char *) name,"frame") == 0) |
1704 | 1637 | { |
1638 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1639 | + | |
1705 | 1640 | /* init the values */ |
1706 | 1641 | width = height = 25; /* these are the values that Magick++ uses */ |
1707 | 1642 | x = y = 6; |
1708 | 1643 | |
1709 | - if (msl_info->image[n] == (Image *) NULL) | |
1710 | - { | |
1711 | - ThrowException(msl_info->exception,OptionError, | |
1712 | - NoImagesDefined,(char *) name); | |
1713 | - break; | |
1714 | - } | |
1715 | 1644 | if (attributes != (const xmlChar **) NULL) |
1716 | 1645 | { |
1717 | 1646 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
1718 | 1647 | { |
1719 | 1648 | keyword=(const char *) attributes[i++]; |
1720 | - if (msl_info->attributes[n] == (Image *) NULL) | |
1721 | - { | |
1722 | - ThrowException(msl_info->exception,OptionError, | |
1723 | - NoImagesDefined,(char *) keyword); | |
1724 | - break; | |
1725 | - } | |
1649 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
1726 | 1650 | value=TranslateText(msl_info->image_info[n], |
1727 | 1651 | msl_info->attributes[n], |
1728 | 1652 | (char *) attributes[i]); |
@@ -1883,12 +1807,8 @@ | ||
1883 | 1807 | double |
1884 | 1808 | gammaRed = 0, gammaGreen = 0, gammaBlue = 0; |
1885 | 1809 | |
1886 | - if (msl_info->image[n] == (Image *) NULL) | |
1887 | - { | |
1888 | - ThrowException(msl_info->exception,OptionError, | |
1889 | - NoImagesDefined,(char *) name); | |
1890 | - break; | |
1891 | - } | |
1810 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
1811 | + | |
1892 | 1812 | if (attributes == (const xmlChar **) NULL) |
1893 | 1813 | break; |
1894 | 1814 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
@@ -1956,12 +1876,9 @@ | ||
1956 | 1876 | } |
1957 | 1877 | else if (LocaleCompare((char *) name,"get") == 0) |
1958 | 1878 | { |
1959 | - if (msl_info->image[n] == (Image *) NULL) | |
1960 | - { | |
1961 | - ThrowException(msl_info->exception,OptionError, | |
1962 | - NoImagesDefined,(char *) name); | |
1963 | - break; | |
1964 | - } | |
1879 | + | |
1880 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->image[n]); | |
1881 | + | |
1965 | 1882 | if (attributes == (const xmlChar **) NULL) |
1966 | 1883 | break; |
1967 | 1884 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
@@ -2054,12 +1971,7 @@ | ||
2054 | 1971 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2055 | 1972 | { |
2056 | 1973 | keyword=(const char *) attributes[i++]; |
2057 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2058 | - { | |
2059 | - ThrowException(msl_info->exception,OptionError, | |
2060 | - NoImagesDefined,(char *) keyword); | |
2061 | - break; | |
2062 | - } | |
1974 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2063 | 1975 | value=TranslateText(msl_info->image_info[n], |
2064 | 1976 | msl_info->attributes[n], |
2065 | 1977 | (char *) attributes[i]); |
@@ -2171,23 +2083,14 @@ | ||
2171 | 2083 | /* init the values */ |
2172 | 2084 | double amount = 0; |
2173 | 2085 | |
2174 | - if (msl_info->image[n] == (Image *) NULL) | |
2175 | - { | |
2176 | - ThrowException(msl_info->exception,OptionError, | |
2177 | - NoImagesDefined,(char *) name); | |
2178 | - break; | |
2179 | - } | |
2086 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2087 | + | |
2180 | 2088 | if (attributes == (const xmlChar **) NULL) |
2181 | 2089 | break; |
2182 | 2090 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2183 | 2091 | { |
2184 | 2092 | keyword=(const char *) attributes[i++]; |
2185 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2186 | - { | |
2187 | - ThrowException(msl_info->exception,OptionError, | |
2188 | - NoImagesDefined,(char *) keyword); | |
2189 | - break; | |
2190 | - } | |
2093 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2191 | 2094 | value=TranslateText(msl_info->image_info[n], |
2192 | 2095 | msl_info->attributes[n], |
2193 | 2096 | (char *) attributes[i]); |
@@ -2244,12 +2147,7 @@ | ||
2244 | 2147 | { |
2245 | 2148 | if (LocaleCompare((char *) name, "magnify") == 0) |
2246 | 2149 | { |
2247 | - if (msl_info->image[n] == (Image *) NULL) | |
2248 | - { | |
2249 | - ThrowException(msl_info->exception,OptionError, | |
2250 | - NoImagesDefined,(char *) name); | |
2251 | - break; | |
2252 | - } | |
2150 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2253 | 2151 | |
2254 | 2152 | /* no attributes here */ |
2255 | 2153 |
@@ -2272,23 +2170,14 @@ | ||
2272 | 2170 | /* init the values */ |
2273 | 2171 | unsigned int radius = 0; |
2274 | 2172 | |
2275 | - if (msl_info->image[n] == (Image *) NULL) | |
2276 | - { | |
2277 | - ThrowException(msl_info->exception,OptionError, | |
2278 | - NoImagesDefined,(char *) name); | |
2279 | - break; | |
2280 | - } | |
2173 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2174 | + | |
2281 | 2175 | if (attributes == (const xmlChar **) NULL) |
2282 | 2176 | break; |
2283 | 2177 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2284 | 2178 | { |
2285 | 2179 | keyword=(const char *) attributes[i++]; |
2286 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2287 | - { | |
2288 | - ThrowException(msl_info->exception,OptionError, | |
2289 | - NoImagesDefined,(char *) keyword); | |
2290 | - break; | |
2291 | - } | |
2180 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2292 | 2181 | value=TranslateText(msl_info->image_info[n], |
2293 | 2182 | msl_info->attributes[n], |
2294 | 2183 | (char *) attributes[i]); |
@@ -2338,12 +2227,8 @@ | ||
2338 | 2227 | } |
2339 | 2228 | else if (LocaleCompare((char *) name, "minify") == 0) |
2340 | 2229 | { |
2341 | - if (msl_info->image[n] == (Image *) NULL) | |
2342 | - { | |
2343 | - ThrowException(msl_info->exception,OptionError, | |
2344 | - NoImagesDefined,(char *) name); | |
2345 | - break; | |
2346 | - } | |
2230 | + | |
2231 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2347 | 2232 | |
2348 | 2233 | /* no attributes here */ |
2349 | 2234 |
@@ -2379,12 +2264,7 @@ | ||
2379 | 2264 | { |
2380 | 2265 | if (LocaleCompare((char *) name, "normalize") == 0) |
2381 | 2266 | { |
2382 | - if (msl_info->image[n] == (Image *) NULL) | |
2383 | - { | |
2384 | - ThrowException(msl_info->exception,OptionError, | |
2385 | - NoImagesDefined,(char *) name); | |
2386 | - break; | |
2387 | - } | |
2267 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2388 | 2268 | |
2389 | 2269 | /* no attributes here */ |
2390 | 2270 |
@@ -2406,23 +2286,14 @@ | ||
2406 | 2286 | /* init the values */ |
2407 | 2287 | unsigned int radius = 3; |
2408 | 2288 | |
2409 | - if (msl_info->image[n] == (Image *) NULL) | |
2410 | - { | |
2411 | - ThrowException(msl_info->exception,OptionError, | |
2412 | - NoImagesDefined,(char *) name); | |
2413 | - break; | |
2414 | - } | |
2289 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2290 | + | |
2415 | 2291 | if (attributes == (const xmlChar **) NULL) |
2416 | 2292 | break; |
2417 | 2293 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2418 | 2294 | { |
2419 | 2295 | keyword=(const char *) attributes[i++]; |
2420 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2421 | - { | |
2422 | - ThrowException(msl_info->exception,OptionError, | |
2423 | - NoImagesDefined,(char *) keyword); | |
2424 | - break; | |
2425 | - } | |
2296 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2426 | 2297 | value=TranslateText(msl_info->image_info[n], |
2427 | 2298 | msl_info->attributes[n], |
2428 | 2299 | (char *) attributes[i]); |
@@ -2486,12 +2357,7 @@ | ||
2486 | 2357 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2487 | 2358 | { |
2488 | 2359 | keyword=(const char *) attributes[i++]; |
2489 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2490 | - { | |
2491 | - ThrowException(msl_info->exception,OptionError, | |
2492 | - NoImagesDefined,(char *) keyword); | |
2493 | - break; | |
2494 | - } | |
2360 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2495 | 2361 | value=TranslateText(msl_info->image_info[n], |
2496 | 2362 | msl_info->attributes[n], |
2497 | 2363 | (char *) attributes[i]); |
@@ -2530,24 +2396,15 @@ | ||
2530 | 2396 | ImageInfo |
2531 | 2397 | *clone_info; |
2532 | 2398 | |
2533 | - if (msl_info->image[n] == (Image *) NULL) | |
2534 | - { | |
2535 | - ThrowException(msl_info->exception,OptionError, | |
2536 | - NoImagesDefined,(char *) name); | |
2537 | - break; | |
2538 | - } | |
2399 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2400 | + | |
2539 | 2401 | if (attributes == (const xmlChar **) NULL) |
2540 | 2402 | break; |
2541 | 2403 | clone_info=CloneImageInfo(msl_info->image_info[n]); |
2542 | 2404 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2543 | 2405 | { |
2544 | 2406 | keyword=(const char *) attributes[i++]; |
2545 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2546 | - { | |
2547 | - ThrowException(msl_info->exception,OptionError, | |
2548 | - NoImagesDefined,(char *) keyword); | |
2549 | - break; | |
2550 | - } | |
2407 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2551 | 2408 | value=TranslateText(msl_info->image_info[n], |
2552 | 2409 | msl_info->attributes[n], |
2553 | 2410 | (char *) attributes[i]); |
@@ -2655,12 +2512,7 @@ | ||
2655 | 2512 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2656 | 2513 | { |
2657 | 2514 | keyword=(const char *) attributes[i++]; |
2658 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2659 | - { | |
2660 | - ThrowException(msl_info->exception,OptionError, | |
2661 | - NoImagesDefined,(char *) keyword); | |
2662 | - break; | |
2663 | - } | |
2515 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2664 | 2516 | value=TranslateText(msl_info->image_info[n], |
2665 | 2517 | msl_info->attributes[n], |
2666 | 2518 | (char *) attributes[i]); |
@@ -2736,23 +2588,14 @@ | ||
2736 | 2588 | /* init the values */ |
2737 | 2589 | unsigned int radius = 0; |
2738 | 2590 | |
2739 | - if (msl_info->image[n] == (Image *) NULL) | |
2740 | - { | |
2741 | - ThrowException(msl_info->exception,OptionError, | |
2742 | - NoImagesDefined,(char *) name); | |
2743 | - break; | |
2744 | - } | |
2591 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2592 | + | |
2745 | 2593 | if (attributes == (const xmlChar **) NULL) |
2746 | 2594 | break; |
2747 | 2595 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2748 | 2596 | { |
2749 | 2597 | keyword=(const char *) attributes[i++]; |
2750 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2751 | - { | |
2752 | - ThrowException(msl_info->exception,OptionError, | |
2753 | - NoImagesDefined,(char *) keyword); | |
2754 | - break; | |
2755 | - } | |
2598 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2756 | 2599 | value=TranslateText(msl_info->image_info[n], |
2757 | 2600 | msl_info->attributes[n], |
2758 | 2601 | (char *) attributes[i]); |
@@ -2802,12 +2645,7 @@ | ||
2802 | 2645 | } |
2803 | 2646 | else if (LocaleCompare((char *) name,"resize") == 0) |
2804 | 2647 | { |
2805 | - if (msl_info->image[n] == (Image *) NULL) | |
2806 | - { | |
2807 | - ThrowException(msl_info->exception,OptionError, | |
2808 | - NoImagesDefined,(char *) name); | |
2809 | - break; | |
2810 | - } | |
2648 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2811 | 2649 | |
2812 | 2650 | /* init the values */ |
2813 | 2651 | width=msl_info->image[n]->columns; |
@@ -2820,12 +2658,7 @@ | ||
2820 | 2658 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2821 | 2659 | { |
2822 | 2660 | keyword=(const char *) attributes[i++]; |
2823 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2824 | - { | |
2825 | - ThrowException(msl_info->exception,OptionError, | |
2826 | - NoImagesDefined,(char *) keyword); | |
2827 | - break; | |
2828 | - } | |
2661 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2829 | 2662 | value=TranslateText(msl_info->image_info[n], |
2830 | 2663 | msl_info->attributes[n], |
2831 | 2664 | (char *) attributes[i]); |
@@ -2936,23 +2769,14 @@ | ||
2936 | 2769 | height=msl_info->image[n]->rows; |
2937 | 2770 | x = y = 0; |
2938 | 2771 | |
2939 | - if (msl_info->image[n] == (Image *) NULL) | |
2940 | - { | |
2941 | - ThrowException(msl_info->exception,OptionError, | |
2942 | - NoImagesDefined,(char *) name); | |
2943 | - break; | |
2944 | - } | |
2772 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2773 | + | |
2945 | 2774 | if (attributes == (const xmlChar **) NULL) |
2946 | 2775 | break; |
2947 | 2776 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
2948 | 2777 | { |
2949 | 2778 | keyword=(const char *) attributes[i++]; |
2950 | - if (msl_info->attributes[n] == (Image *) NULL) | |
2951 | - { | |
2952 | - ThrowException(msl_info->exception,OptionError, | |
2953 | - NoImagesDefined,(char *) keyword); | |
2954 | - break; | |
2955 | - } | |
2779 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
2956 | 2780 | value=TranslateText(msl_info->image_info[n], |
2957 | 2781 | msl_info->attributes[n], |
2958 | 2782 | (char *) attributes[i]); |
@@ -3030,23 +2854,14 @@ | ||
3030 | 2854 | /* init the values */ |
3031 | 2855 | double degrees = 0; |
3032 | 2856 | |
3033 | - if (msl_info->image[n] == (Image *) NULL) | |
3034 | - { | |
3035 | - ThrowException(msl_info->exception,OptionError, | |
3036 | - NoImagesDefined,(char *) name); | |
3037 | - break; | |
3038 | - } | |
2857 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2858 | + | |
3039 | 2859 | if (attributes == (const xmlChar **) NULL) |
3040 | 2860 | break; |
3041 | 2861 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3042 | 2862 | { |
3043 | 2863 | keyword=(const char *) attributes[i++]; |
3044 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3045 | - { | |
3046 | - ThrowException(msl_info->exception,OptionError, | |
3047 | - NoImagesDefined,(char *) keyword); | |
3048 | - break; | |
3049 | - } | |
2864 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3050 | 2865 | value=TranslateText(msl_info->image_info[n], |
3051 | 2866 | msl_info->attributes[n], |
3052 | 2867 | (char *) attributes[i]); |
@@ -3104,28 +2919,19 @@ | ||
3104 | 2919 | { |
3105 | 2920 | if (LocaleCompare((char *) name,"sample") == 0) |
3106 | 2921 | { |
2922 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
2923 | + | |
3107 | 2924 | /* init the values */ |
3108 | 2925 | width=msl_info->image[n]->columns; |
3109 | 2926 | height=msl_info->image[n]->rows; |
3110 | 2927 | x = y = 0; |
3111 | 2928 | |
3112 | - if (msl_info->image[n] == (Image *) NULL) | |
3113 | - { | |
3114 | - ThrowException(msl_info->exception,OptionError, | |
3115 | - NoImagesDefined,(char *) name); | |
3116 | - break; | |
3117 | - } | |
3118 | 2929 | if (attributes == (const xmlChar **) NULL) |
3119 | 2930 | break; |
3120 | 2931 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3121 | 2932 | { |
3122 | 2933 | keyword=(const char *) attributes[i++]; |
3123 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3124 | - { | |
3125 | - ThrowException(msl_info->exception,OptionError, | |
3126 | - NoImagesDefined,(char *) keyword); | |
3127 | - break; | |
3128 | - } | |
2934 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3129 | 2935 | value=TranslateText(msl_info->image_info[n], |
3130 | 2936 | msl_info->attributes[n], |
3131 | 2937 | (char *) attributes[i]); |
@@ -3200,28 +3006,19 @@ | ||
3200 | 3006 | } |
3201 | 3007 | else if (LocaleCompare((char *) name,"scale") == 0) |
3202 | 3008 | { |
3009 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3010 | + | |
3203 | 3011 | /* init the values */ |
3204 | 3012 | width=msl_info->image[n]->columns; |
3205 | 3013 | height=msl_info->image[n]->rows; |
3206 | 3014 | x = y = 0; |
3207 | 3015 | |
3208 | - if (msl_info->image[n] == (Image *) NULL) | |
3209 | - { | |
3210 | - ThrowException(msl_info->exception,OptionError, | |
3211 | - NoImagesDefined,(char *) name); | |
3212 | - break; | |
3213 | - } | |
3214 | 3016 | if (attributes == (const xmlChar **) NULL) |
3215 | 3017 | break; |
3216 | 3018 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3217 | 3019 | { |
3218 | 3020 | keyword=(const char *) attributes[i++]; |
3219 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3220 | - { | |
3221 | - ThrowException(msl_info->exception,OptionError, | |
3222 | - NoImagesDefined,(char *) keyword); | |
3223 | - break; | |
3224 | - } | |
3021 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3225 | 3022 | value=TranslateText(msl_info->image_info[n], |
3226 | 3023 | msl_info->attributes[n], |
3227 | 3024 | (char *) attributes[i]); |
@@ -3296,24 +3093,14 @@ | ||
3296 | 3093 | } |
3297 | 3094 | else if (LocaleCompare((char *) name, "set") == 0) |
3298 | 3095 | { |
3299 | - if (msl_info->image[n] == (Image *) NULL) | |
3300 | - { | |
3301 | - ThrowException(msl_info->exception,OptionError, | |
3302 | - NoImagesDefined,(char *) name); | |
3303 | - break; | |
3304 | - } | |
3096 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->image[n]); | |
3305 | 3097 | |
3306 | 3098 | if (attributes == (const xmlChar **) NULL) |
3307 | 3099 | break; |
3308 | 3100 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3309 | 3101 | { |
3310 | 3102 | keyword=(const char *) attributes[i++]; |
3311 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3312 | - { | |
3313 | - ThrowException(msl_info->exception,OptionError, | |
3314 | - NoImagesDefined,(char *) keyword); | |
3315 | - break; | |
3316 | - } | |
3103 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3317 | 3104 | value=TranslateText(msl_info->image_info[n], |
3318 | 3105 | msl_info->attributes[n], |
3319 | 3106 | (char *) attributes[i]); |
@@ -3471,23 +3258,14 @@ | ||
3471 | 3258 | double radius = 0.0, |
3472 | 3259 | sigma = 1.0; |
3473 | 3260 | |
3474 | - if (msl_info->image[n] == (Image *) NULL) | |
3475 | - { | |
3476 | - ThrowException(msl_info->exception,OptionError, | |
3477 | - NoImagesDefined,(char *) name); | |
3478 | - break; | |
3479 | - } | |
3261 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3262 | + | |
3480 | 3263 | if (attributes != (const xmlChar **) NULL) |
3481 | 3264 | { |
3482 | 3265 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3483 | 3266 | { |
3484 | 3267 | keyword=(const char *) attributes[i++]; |
3485 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3486 | - { | |
3487 | - ThrowException(msl_info->exception,OptionError, | |
3488 | - NoImagesDefined,(char *) keyword); | |
3489 | - break; | |
3490 | - } | |
3268 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3491 | 3269 | value=TranslateText(msl_info->image_info[n], |
3492 | 3270 | msl_info->attributes[n], |
3493 | 3271 | (char *) attributes[i]); |
@@ -3554,23 +3332,14 @@ | ||
3554 | 3332 | width = height = 0; |
3555 | 3333 | x = y = 0; |
3556 | 3334 | |
3557 | - if (msl_info->image[n] == (Image *) NULL) | |
3558 | - { | |
3559 | - ThrowException(msl_info->exception,OptionError, | |
3560 | - NoImagesDefined,(char *) name); | |
3561 | - break; | |
3562 | - } | |
3335 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3336 | + | |
3563 | 3337 | if (attributes == (const xmlChar **) NULL) |
3564 | 3338 | break; |
3565 | 3339 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3566 | 3340 | { |
3567 | 3341 | keyword=(const char *) attributes[i++]; |
3568 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3569 | - { | |
3570 | - ThrowException(msl_info->exception,OptionError, | |
3571 | - NoImagesDefined,(char *) keyword); | |
3572 | - break; | |
3573 | - } | |
3342 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3574 | 3343 | value=TranslateText(msl_info->image_info[n], |
3575 | 3344 | msl_info->attributes[n], |
3576 | 3345 | (char *) attributes[i]); |
@@ -3653,28 +3422,19 @@ | ||
3653 | 3422 | } |
3654 | 3423 | else if (LocaleCompare((char *) name,"shear") == 0) |
3655 | 3424 | { |
3425 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3426 | + | |
3656 | 3427 | /* init the values */ |
3657 | 3428 | width=msl_info->image[n]->columns; |
3658 | 3429 | height=msl_info->image[n]->rows; |
3659 | 3430 | x = y = 0; |
3660 | 3431 | |
3661 | - if (msl_info->image[n] == (Image *) NULL) | |
3662 | - { | |
3663 | - ThrowException(msl_info->exception,OptionError, | |
3664 | - NoImagesDefined,(char *) name); | |
3665 | - break; | |
3666 | - } | |
3667 | 3432 | if (attributes == (const xmlChar **) NULL) |
3668 | 3433 | break; |
3669 | 3434 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3670 | 3435 | { |
3671 | 3436 | keyword=(const char *) attributes[i++]; |
3672 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3673 | - { | |
3674 | - ThrowException(msl_info->exception,OptionError, | |
3675 | - NoImagesDefined,(char *) keyword); | |
3676 | - break; | |
3677 | - } | |
3437 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3678 | 3438 | value=TranslateText(msl_info->image_info[n], |
3679 | 3439 | msl_info->attributes[n], |
3680 | 3440 | (char *) attributes[i]); |
@@ -3740,23 +3500,14 @@ | ||
3740 | 3500 | /* init the values */ |
3741 | 3501 | double threshold = 0; |
3742 | 3502 | |
3743 | - if (msl_info->image[n] == (Image *) NULL) | |
3744 | - { | |
3745 | - ThrowException(msl_info->exception,OptionError, | |
3746 | - NoImagesDefined,(char *) name); | |
3747 | - break; | |
3748 | - } | |
3503 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3504 | + | |
3749 | 3505 | if (attributes == (const xmlChar **) NULL) |
3750 | 3506 | break; |
3751 | 3507 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3752 | 3508 | { |
3753 | 3509 | keyword=(const char *) attributes[i++]; |
3754 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3755 | - { | |
3756 | - ThrowException(msl_info->exception,OptionError, | |
3757 | - NoImagesDefined,(char *) keyword); | |
3758 | - break; | |
3759 | - } | |
3510 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3760 | 3511 | value=TranslateText(msl_info->image_info[n], |
3761 | 3512 | msl_info->attributes[n], |
3762 | 3513 | (char *) attributes[i]); |
@@ -3801,23 +3552,14 @@ | ||
3801 | 3552 | /* init the values */ |
3802 | 3553 | unsigned int radius = 0; |
3803 | 3554 | |
3804 | - if (msl_info->image[n] == (Image *) NULL) | |
3805 | - { | |
3806 | - ThrowException(msl_info->exception,OptionError, | |
3807 | - NoImagesDefined,(char *) name); | |
3808 | - break; | |
3809 | - } | |
3555 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3556 | + | |
3810 | 3557 | if (attributes == (const xmlChar **) NULL) |
3811 | 3558 | break; |
3812 | 3559 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3813 | 3560 | { |
3814 | 3561 | keyword=(const char *) attributes[i++]; |
3815 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3816 | - { | |
3817 | - ThrowException(msl_info->exception,OptionError, | |
3818 | - NoImagesDefined,(char *) keyword); | |
3819 | - break; | |
3820 | - } | |
3562 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3821 | 3563 | value=TranslateText(msl_info->image_info[n], |
3822 | 3564 | msl_info->attributes[n], |
3823 | 3565 | (char *) attributes[i]); |
@@ -3870,23 +3612,14 @@ | ||
3870 | 3612 | Image * |
3871 | 3613 | watermark = (Image*)NULL; |
3872 | 3614 | |
3873 | - if (msl_info->image[n] == (Image *) NULL) | |
3874 | - { | |
3875 | - ThrowException(msl_info->exception,OptionError, | |
3876 | - NoImagesDefined,(char *) name); | |
3877 | - break; | |
3878 | - } | |
3615 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3616 | + | |
3879 | 3617 | if (attributes == (const xmlChar **) NULL) |
3880 | 3618 | break; |
3881 | 3619 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3882 | 3620 | { |
3883 | 3621 | keyword=(const char *) attributes[i++]; |
3884 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3885 | - { | |
3886 | - ThrowException(msl_info->exception,OptionError, | |
3887 | - NoImagesDefined,(char *) keyword); | |
3888 | - break; | |
3889 | - } | |
3622 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3890 | 3623 | value=TranslateText(msl_info->image_info[n], |
3891 | 3624 | msl_info->attributes[n], |
3892 | 3625 | (char *) attributes[i]); |
@@ -3953,23 +3686,14 @@ | ||
3953 | 3686 | Image * |
3954 | 3687 | stereoImage = (Image*)NULL; |
3955 | 3688 | |
3956 | - if (msl_info->image[n] == (Image *) NULL) | |
3957 | - { | |
3958 | - ThrowException(msl_info->exception,OptionError, | |
3959 | - NoImagesDefined,(char *) name); | |
3960 | - break; | |
3961 | - } | |
3689 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3690 | + | |
3962 | 3691 | if (attributes == (const xmlChar **) NULL) |
3963 | 3692 | break; |
3964 | 3693 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
3965 | 3694 | { |
3966 | 3695 | keyword=(const char *) attributes[i++]; |
3967 | - if (msl_info->attributes[n] == (Image *) NULL) | |
3968 | - { | |
3969 | - ThrowException(msl_info->exception,OptionError, | |
3970 | - NoImagesDefined,(char *) keyword); | |
3971 | - break; | |
3972 | - } | |
3696 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
3973 | 3697 | value=TranslateText(msl_info->image_info[n], |
3974 | 3698 | msl_info->attributes[n], |
3975 | 3699 | (char *) attributes[i]); |
@@ -4036,23 +3760,14 @@ | ||
4036 | 3760 | /* init the values */ |
4037 | 3761 | double degrees = 0; |
4038 | 3762 | |
4039 | - if (msl_info->image[n] == (Image *) NULL) | |
4040 | - { | |
4041 | - ThrowException(msl_info->exception,OptionError, | |
4042 | - NoImagesDefined,(char *) name); | |
4043 | - break; | |
4044 | - } | |
3763 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3764 | + | |
4045 | 3765 | if (attributes == (const xmlChar **) NULL) |
4046 | 3766 | break; |
4047 | 3767 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
4048 | 3768 | { |
4049 | 3769 | keyword=(const char *) attributes[i++]; |
4050 | - if (msl_info->attributes[n] == (Image *) NULL) | |
4051 | - { | |
4052 | - ThrowException(msl_info->exception,OptionError, | |
4053 | - NoImagesDefined,(char *) keyword); | |
4054 | - break; | |
4055 | - } | |
3770 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
4056 | 3771 | value=TranslateText(msl_info->image_info[n], |
4057 | 3772 | msl_info->attributes[n], |
4058 | 3773 | (char *) attributes[i]); |
@@ -4149,12 +3864,7 @@ | ||
4149 | 3864 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
4150 | 3865 | { |
4151 | 3866 | keyword=(const char *) attributes[i++]; |
4152 | - if (msl_info->attributes[n] == (Image *) NULL) | |
4153 | - { | |
4154 | - ThrowException(msl_info->exception,OptionError, | |
4155 | - NoImagesDefined,(char *) keyword); | |
4156 | - break; | |
4157 | - } | |
3867 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
4158 | 3868 | value=TranslateText(msl_info->image_info[n], |
4159 | 3869 | msl_info->attributes[n], |
4160 | 3870 | (char *) attributes[i]); |
@@ -4214,23 +3924,14 @@ | ||
4214 | 3924 | /* init the values */ |
4215 | 3925 | double threshold = 0; |
4216 | 3926 | |
4217 | - if (msl_info->image[n] == (Image *) NULL) | |
4218 | - { | |
4219 | - ThrowException(msl_info->exception,OptionError, | |
4220 | - NoImagesDefined,(char *) name); | |
4221 | - break; | |
4222 | - } | |
3927 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3928 | + | |
4223 | 3929 | if (attributes == (const xmlChar **) NULL) |
4224 | 3930 | break; |
4225 | 3931 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
4226 | 3932 | { |
4227 | 3933 | keyword=(const char *) attributes[i++]; |
4228 | - if (msl_info->attributes[n] == (Image *) NULL) | |
4229 | - { | |
4230 | - ThrowException(msl_info->exception,OptionError, | |
4231 | - NoImagesDefined,(char *) keyword); | |
4232 | - break; | |
4233 | - } | |
3934 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
4234 | 3935 | value=TranslateText(msl_info->image_info[n], |
4235 | 3936 | msl_info->attributes[n], |
4236 | 3937 | (char *) attributes[i]); |
@@ -4275,23 +3976,15 @@ | ||
4275 | 3976 | } |
4276 | 3977 | else if (LocaleCompare((char *) name, "transparent") == 0) |
4277 | 3978 | { |
4278 | - if (msl_info->image[n] == (Image *) NULL) | |
4279 | - { | |
4280 | - ThrowException(msl_info->exception,OptionError, | |
4281 | - NoImagesDefined,(char *) name); | |
4282 | - break; | |
4283 | - } | |
3979 | + | |
3980 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
3981 | + | |
4284 | 3982 | if (attributes == (const xmlChar **) NULL) |
4285 | 3983 | break; |
4286 | 3984 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
4287 | 3985 | { |
4288 | 3986 | keyword=(const char *) attributes[i++]; |
4289 | - if (msl_info->attributes[n] == (Image *) NULL) | |
4290 | - { | |
4291 | - ThrowException(msl_info->exception,OptionError, | |
4292 | - NoImagesDefined,(char *) keyword); | |
4293 | - break; | |
4294 | - } | |
3987 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
4295 | 3988 | value=TranslateText(msl_info->image_info[n], |
4296 | 3989 | msl_info->attributes[n], |
4297 | 3990 | (char *) attributes[i]); |
@@ -4335,12 +4028,7 @@ | ||
4335 | 4028 | } |
4336 | 4029 | else if (LocaleCompare((char *) name, "trim") == 0) |
4337 | 4030 | { |
4338 | - if (msl_info->image[n] == (Image *) NULL) | |
4339 | - { | |
4340 | - ThrowException(msl_info->exception,OptionError, | |
4341 | - NoImagesDefined,(char *) name); | |
4342 | - break; | |
4343 | - } | |
4031 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
4344 | 4032 | |
4345 | 4033 | /* no attributes here */ |
4346 | 4034 |
@@ -4373,23 +4061,14 @@ | ||
4373 | 4061 | { |
4374 | 4062 | if (LocaleCompare((char *) name,"write") == 0) |
4375 | 4063 | { |
4376 | - if (msl_info->image[n] == (Image *) NULL) | |
4377 | - { | |
4378 | - ThrowException(msl_info->exception,OptionError, | |
4379 | - NoImagesDefined,(char *) name); | |
4380 | - break; | |
4381 | - } | |
4064 | + MSL_BREAK_IF_IMAGE_NOT_INSTANTIATED(msl_info->image[n]); | |
4065 | + | |
4382 | 4066 | if (attributes == (const xmlChar **) NULL) |
4383 | 4067 | break; |
4384 | 4068 | for (i=0; (attributes[i] != (const xmlChar *) NULL); i++) |
4385 | 4069 | { |
4386 | 4070 | keyword=(const char *) attributes[i++]; |
4387 | - if (msl_info->attributes[n] == (Image *) NULL) | |
4388 | - { | |
4389 | - ThrowException(msl_info->exception,OptionError, | |
4390 | - NoImagesDefined,(char *) keyword); | |
4391 | - break; | |
4392 | - } | |
4071 | + MSL_BREAK_IF_IMAGE_NULL(msl_info->attributes[n]); | |
4393 | 4072 | value=TranslateText(msl_info->image_info[n], |
4394 | 4073 | msl_info->attributes[n], |
4395 | 4074 | (char *) attributes[i]); |
@@ -1029,27 +1029,7 @@ | ||
1029 | 1029 | Matrix is not square (%s elements) |
1030 | 1030 | </Message> |
1031 | 1031 | <Message name="RegionAreaExceedsLimit"> |
1032 | - Region area exceeds implementation limit | |
1033 | - </Message> | |
1034 | - <Message name="MissingAnImageFilename"> | |
1035 | - Missing an image filename | |
1036 | - </Message> | |
1037 | - <Message name="MissingArgument"> | |
1038 | - Option '%s' requires an argument or argument is malformed | |
1039 | - </Message> | |
1040 | - <Message name="MustSpecifyAnImageName"> | |
1041 | - Must specify a image name | |
1042 | - </Message> | |
1043 | - <Message name="MustSpecifyImageSize"> | |
1044 | - Must specify image size | |
1045 | - </Message> | |
1046 | - <Message name="NoBlobDefined"> | |
1047 | - No Binary Large OBjects defined | |
1048 | - </Message> | |
1049 | - <Message name="NoImagesDefined"> | |
1050 | - No images defined | |
1051 | - </Message> | |
1052 | - <Message name="NonzeroWidthAndHeightRequired"> | |
1032 | +NonzeroWidthAndHeightRequired"> | |
1053 | 1033 | Non-zero width and height required |
1054 | 1034 | </Message> |
1055 | 1035 | <Message name="NoProfileNameWasGiven"> |
@@ -1,5 +1,5 @@ | ||
1 | 1 | /* |
2 | -% Copyright (C) 2003 - 2020 GraphicsMagick Group | |
2 | +% Copyright (C) 2003 - 2021 GraphicsMagick Group | |
3 | 3 | % Copyright (C) 2002 ImageMagick Studio |
4 | 4 | % Copyright 1991-1999 E. I. du Pont de Nemours and Company |
5 | 5 | % |
@@ -1515,6 +1515,8 @@ | ||
1515 | 1515 | */ |
1516 | 1516 | assert(image != (const Image *) NULL); |
1517 | 1517 | assert(image->signature == MagickSignature); |
1518 | + assert(image->columns != 0); | |
1519 | + assert(image->rows != 0); | |
1518 | 1520 | assert(exception != (ExceptionInfo *) NULL); |
1519 | 1521 | assert(exception->signature == MagickSignature); |
1520 | 1522 | roll_image=CloneImage(image,image->columns,image->rows,True,exception); |
@@ -38,8 +38,8 @@ | ||
38 | 38 | #define MagickLibVersion 0x252200 |
39 | 39 | #define MagickLibVersionText "1.4" |
40 | 40 | #define MagickLibVersionNumber 25,22,0 |
41 | -#define MagickChangeDate "20210716" | |
42 | -#define MagickReleaseDate "snapshot-20210716" | |
41 | +#define MagickChangeDate "20210718" | |
42 | +#define MagickReleaseDate "snapshot-20210718" | |
43 | 43 | |
44 | 44 | /* |
45 | 45 | The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines |
@@ -35,6 +35,16 @@ | ||
35 | 35 | <div class="document"> |
36 | 36 | |
37 | 37 | |
38 | +<p>2021-07-18 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> | |
39 | +<blockquote> | |
40 | +<p>* coders/msl.c (MSLStartElement): Use macros to simplify | |
41 | +validations and reduce repeated code fragments. Add validations | |
42 | +for image size and pixels present where applicable. Fixes | |
43 | +oss-fuzz 36224 "graphicsmagick:coder_MSL_fuzzer: Timeout in | |
44 | +coder_MSL_fuzzer".</p> | |
45 | +<p>* magick/transform.c (RollImage): Assert that image rows and | |
46 | +columns are not zero.</p> | |
47 | +</blockquote> | |
38 | 48 | <p>2021-07-16 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> |
39 | 49 | <blockquote> |
40 | 50 | * coders/jp2.c (initialize_jasper): Update for the latest version |