OSDN Git Service

use memcmp() instead of qstrncmp() when checking image headers
authorIvailo Monev <xakepa10@gmail.com>
Thu, 13 Oct 2022 22:31:35 +0000 (01:31 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 13 Oct 2022 22:31:35 +0000 (01:31 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qkathandler.cpp
src/gui/image/qpnghandler.cpp

index 094c483..786c6a6 100644 (file)
@@ -60,7 +60,7 @@ bool QKatHandler::canRead(QIODevice *device)
     if (device->peek(head, sizeof(head)) != sizeof(head))
         return false;
 
-    return (qstrncmp(head, "KATIE", 5) == 0);
+    return (::memcmp(head, "KATIE", 5) == 0);
 }
 
 bool QKatHandler::read(QImage *image)
@@ -69,7 +69,7 @@ bool QKatHandler::read(QImage *image)
 
     QSTACKARRAY(char, header, 5);
     imagestream.readRawData(header, 5);
-    if (Q_UNLIKELY(qstrncmp(header, "KATIE", 5) != 0)) {
+    if (Q_UNLIKELY(::memcmp(header, "KATIE", 5) != 0)) {
         qWarning("QKatHandler::read() Invalid header (%s)", header);
         *image = QImage();
         return false;
index 25f3d17..2f8f55c 100644 (file)
@@ -317,7 +317,7 @@ bool QPngHandler::canRead(QIODevice *device)
 
     static const uchar pngheader[]
         = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
-    return (qstrncmp(head, reinterpret_cast<const char*>(pngheader), 8) == 0);
+    return (::memcmp(head, pngheader, 8) == 0);
 }
 
 QT_END_NAMESPACE