Commit fd19aa37 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

edid: Do not access unallocated QByteArrays

We are assigning to it 3 different values, we better have memory
allocated for it.

This fixes a warning from QByteArray that says such accesses are
unsupported.
parent ee37d80e
...@@ -264,23 +264,22 @@ bool Edid::Private::parse(const QByteArray &rawData) ...@@ -264,23 +264,22 @@ bool Edid::Private::parse(const QByteArray &rawData)
* 7654321076543210 * 7654321076543210
* |\---/\---/\---/ * |\---/\---/\---/
* R C1 C2 C3 */ * R C1 C2 C3 */
pnpId.resize(3);
pnpId[0] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x7c) / 4) - 1; pnpId[0] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x7c) / 4) - 1;
pnpId[1] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x3) * 8) + ((data[GCM_EDID_OFFSET_PNPID+1] & 0xe0) / 32) - 1; pnpId[1] = 'A' + ((data[GCM_EDID_OFFSET_PNPID + 0] & 0x3) * 8) + ((data[GCM_EDID_OFFSET_PNPID+1] & 0xe0) / 32) - 1;
pnpId[2] = 'A' + (data[GCM_EDID_OFFSET_PNPID + 1] & 0x1f) - 1; pnpId[2] = 'A' + (data[GCM_EDID_OFFSET_PNPID + 1] & 0x1f) - 1;
// load the PNP_IDS file and load the vendor name // load the PNP_IDS file and load the vendor name
if (!pnpId.isEmpty()) { QFile pnpIds(QStringLiteral(PNP_IDS));
QFile pnpIds(QStringLiteral(PNP_IDS)); if (pnpIds.open(QIODevice::ReadOnly)) {
if (pnpIds.open(QIODevice::ReadOnly)) { while (!pnpIds.atEnd()) {
while (!pnpIds.atEnd()) { QString line = QString::fromUtf8(pnpIds.readLine());
QString line = QString::fromUtf8(pnpIds.readLine()); if (line.startsWith(pnpId)) {
if (line.startsWith(pnpId)) { QStringList parts = line.split(QLatin1Char('\t'));
QStringList parts = line.split(QLatin1Char('\t')); if (parts.size() == 2) {
if (parts.size() == 2) { vendorName = line.split(QLatin1Char('\t')).at(1).simplified();
vendorName = line.split(QLatin1Char('\t')).at(1).simplified();
}
break;
} }
break;
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment