diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp
index b9047f9..f526589 100644
--- a/source/Lib/EncoderLib/IntraSearch.cpp
+++ b/source/Lib/EncoderLib/IntraSearch.cpp
@@ -2030,7 +2030,7 @@ void IntraSearch::preCalcPLTIndex(CodingStructure& cs, Partitioner& partitioner,
   }
 
   PelBuf   curPLTIdx = tu.getcurPLTIdx(compBegin);
-  int      errorLimit = numComp * g_paletteQuant[cu.qp];
+  int      errorLimit = numComp * g_paletteQuant[cu.qp < 0 ? 0 : cu.qp];
   uint32_t bestIdx = 0;
   uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc());
   uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc());
@@ -2167,7 +2167,7 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner,
     }
   }
 
-  int errorLimit = g_paletteQuant[cu.qp];
+  int errorLimit = g_paletteQuant[cu.qp < 0 ? 0 : cu.qp];
   uint32_t totalSize = height*width;
   SortingElement *pelList = new SortingElement[totalSize];
   SortingElement  element;
