Commit cf226215 authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Fix three coverity issues

Reported here:
https://mail.kde.org/pipermail/konsole-devel/2022-July/041429.html

- Use delete[] to free array allocated with new.
- Don't separate two cases which are handled identically.
- In vt100 parsing state machine no need to handle in specific states
  characters which are handles identically in all states.

(cherry picked from commit 24b0c08d)
parent 23ff7d5a
Pipeline #206615 passed with stage
in 3 minutes and 34 seconds
......@@ -1935,7 +1935,7 @@ int Screen::copyLineToStream(int line,
decoder->decodeLine(newBuffer, count, currentLineProperties);
if (todel) {
delete newBuffer;
delete[] newBuffer;
}
return count;
......
......@@ -868,16 +868,12 @@ void Vt102Emulation::receiveChars(const QVector<uint> &chars)
case DcsPassthrough:
if (cc <= 0x7E || cc >= 0xA0) { // 0x18, 0x1A, 0x1B already taken care of
put(cc);
} else if (cc == 0x9C) {
switchState(Ground, cc);
} else if (cc == 0x7F) {
// ignore
}
break;
case DcsIgnore:
if (cc == 0x9C) {
switchState(Ground, cc);
} else if (cc <= 0x7F) {
if (cc <= 0x7F) {
// ignore
}
break;
......@@ -894,9 +890,6 @@ void Vt102Emulation::receiveChars(const QVector<uint> &chars)
case SosPmApcString:
if (cc <= 0x7F || cc >= 0xA0) { // 0x18, 0x1A, 0x1B already taken care of.
apc_put(cc);
// ignore
} else if (cc == 0x9C) {
switchState(Ground, cc);
}
break;
default:
......@@ -2147,11 +2140,7 @@ void Vt102Emulation::emulateUpDown(bool up, KeyboardTranslator::Entry entry, QBy
}
}
if (toCol > -1) {
if (toCol < realX) {
num += up ? realX - toCol : toCol - realX;
} else {
num += up ? realX - toCol : toCol - realX;
}
num += up ? realX - toCol : toCol - realX;
}
for (int i = 1; i < num; i++) {
// One more will be added by the rest of the code.
......
Supports Markdown
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