Remove lcms patches to cmsDupToneCurve()

The crashes these patches fixed are no longer applicable to modern lcms,
which has proper fixes for those issues. Removing the patches reduces
the maintenance burden, and also fixes a functional bug with ICC version
4 profiles.

Bug: chromium:1432571
Change-Id: I77df2bd8f9d1ff1c2703609749a5348918dab095
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/106010
Reviewed-by: K. Moon <kmoon@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/third_party/lcms/0002-old-performance-fix.patch b/third_party/lcms/0002-old-performance-fix.patch
deleted file mode 100644
index cea2bee..0000000
--- a/third_party/lcms/0002-old-performance-fix.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/third_party/lcms/src/cmsgamma.c b/third_party/lcms/src/cmsgamma.c
-index edb8f6bba..eb3dd881c 100644
---- a/third_party/lcms/src/cmsgamma.c
-+++ b/third_party/lcms/src/cmsgamma.c
-@@ -799,7 +799,7 @@ void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3])
- // Duplicate a gamma table
- cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* In)
- {
--    if (In == NULL) return NULL;
-+    if (In == NULL || In ->Segments == NULL || In ->Table16 == NULL) return NULL;
- 
-     return  AllocateToneCurveStruct(In ->InterpParams ->ContextID, In ->nEntries, In ->nSegments, In ->Segments, In ->Table16);
- }
diff --git a/third_party/lcms/0027-changes-from-beginning-of-time.patch b/third_party/lcms/0027-changes-from-beginning-of-time.patch
index 7ef1db4..7d9264e 100644
--- a/third_party/lcms/0027-changes-from-beginning-of-time.patch
+++ b/third_party/lcms/0027-changes-from-beginning-of-time.patch
@@ -68,18 +68,6 @@
  
      _cmsFree(ContextID, Curve);
  }
-@@ -799,7 +814,10 @@ void CMSEXPORT cmsFreeToneCurveTriple(cmsToneCurve* Curve[3])
- // Duplicate a gamma table
- cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* In)
- {
--    if (In == NULL || In ->Segments == NULL || In ->Table16 == NULL) return NULL;
-+    // Xiaochuan Liu
-+    // fix openpdf bug(mantis id:0055683, google id:360198)
-+    // the function CurveSetElemTypeFree in cmslut.c also needs to check pointer
-+    if (In == NULL || In ->InterpParams == NULL || In ->Segments == NULL || In ->Table16 == NULL) return NULL;
- 
-     return  AllocateToneCurveStruct(In ->InterpParams ->ContextID, In ->nEntries, In ->nSegments, In ->Segments, In ->Table16);
- }
 diff --git a/third_party/lcms/src/cmsio0.c b/third_party/lcms/src/cmsio0.c
 index 1b026488d..cc5f89064 100644
 --- a/third_party/lcms/src/cmsio0.c
diff --git a/third_party/lcms/README.pdfium b/third_party/lcms/README.pdfium
index 1dbef7c..b71c6f2 100644
--- a/third_party/lcms/README.pdfium
+++ b/third_party/lcms/README.pdfium
@@ -11,7 +11,6 @@
 
 0000-cmserr-changes.patch: change LCMS memory management methods to use PDFium's.
 0001-fix-include.patch: fix include in lcms2_internal.h.
-0002-old-performance-fix.patch: https://codereview.chromium.org/534363002/
 0003-old-uninitialized-in-LUTevalFloat.patch: https://codereview.chromium.org/380293002/
 0004-old-uninitialized-in-LUTeval16.patch: https://codereview.chromium.org/387273002/
 0006-tag-type-confusion.patch: Fix a type confusion.
diff --git a/third_party/lcms/src/cmsgamma.c b/third_party/lcms/src/cmsgamma.c
index 524c4ee..0c8d0f3 100644
--- a/third_party/lcms/src/cmsgamma.c
+++ b/third_party/lcms/src/cmsgamma.c
@@ -969,10 +969,7 @@
 // Duplicate a gamma table
 cmsToneCurve* CMSEXPORT cmsDupToneCurve(const cmsToneCurve* In)
 {
-    // Xiaochuan Liu
-    // fix openpdf bug(mantis id:0055683, google id:360198)
-    // the function CurveSetElemTypeFree in cmslut.c also needs to check pointer
-    if (In == NULL || In ->InterpParams == NULL || In ->Segments == NULL || In ->Table16 == NULL) return NULL;
+    if (In == NULL) return NULL;
 
     return  AllocateToneCurveStruct(In ->InterpParams ->ContextID, In ->nEntries, In ->nSegments, In ->Segments, In ->Table16);
 }