diff --git a/engines/saga2/gtextbox.cpp b/engines/saga2/gtextbox.cpp index aeb39db2089..a5cdcf6202c 100644 --- a/engines/saga2/gtextbox.cpp +++ b/engines/saga2/gtextbox.cpp @@ -181,7 +181,7 @@ gTextBox::gTextBox( flags = flg; currentLen[index] = buffer ? strlen(buffer) : 0; cursorPos = anchorPos = scrollPixels = 0; - undoBuffer = (char *)malloc(sizeof(char) * (maxLen + 1)); + undoBuffer = new char[maxLen + 1](); textFont = font; fontHeight = height; fontOffset = fontHeight + 2; @@ -233,7 +233,7 @@ gTextBox::~gTextBox() { deSelect(); selected = 0; if (undoBuffer) { - delete undoBuffer; + delete[] undoBuffer; } } diff --git a/engines/saga2/uidialog.cpp b/engines/saga2/uidialog.cpp index ac13972d009..7b735d79904 100644 --- a/engines/saga2/uidialog.cpp +++ b/engines/saga2/uidialog.cpp @@ -593,11 +593,12 @@ void destroyFileFields(char **strings) { uint16 i; for (i = 0; i < numEditLines; i++) { - if (strings[i]) delete strings[i]; - strings[i] = NULL; + if (strings[i]) + delete[] strings[i]; + strings[i] = nullptr; } - delete strings; + delete[] strings; } bool getSaveName(int8 saveNo, SaveFileHeader &header) { diff --git a/engines/saga2/vwdraw.cpp b/engines/saga2/vwdraw.cpp index d6eacdc34ea..a046179086b 100644 --- a/engines/saga2/vwdraw.cpp +++ b/engines/saga2/vwdraw.cpp @@ -66,7 +66,8 @@ void gDisplayPort::bltPixels( sect; uint8 *src_line; - clip = Rect16(0, 0, map->size.x, map->size.y); + if (clip.empty()) + clip = Rect16(0, 0, map->size.x, map->size.y); sect = intersect(clip, r); if (!sect.empty()) { // if result is non-empty