[haiku-commits] haiku: hrev52836 - in src: apps/mail kits/support kits/midi2

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 3 Feb 2019 13:05:57 -0500 (EST)

hrev52836 adds 3 changesets to branch 'master'
old head: e5d0c9094d6e01bb29b6ad4c9a43b0ab5e800b8b
new head: f465c7fa619a31eabf63b5e8d72edcdf78982c8e
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=f465c7fa619a+%5Ee5d0c9094d6e

----------------------------------------------------------------------------

6c67c7d635df: support/String: Fix PVS 626
  
  Fix memory leak when realloc() fails.
  
  Change-Id: I5b44df57bdd251e5164938ed70412c909ce09df1
  Reviewed-on: https://review.haiku-os.org/c/1004
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

21392fa9b149: mail: Fix PVS 965
  
  Fix memory leak when realloc() fails.
  
  Change-Id: I8f7fb3ce7f43de03f76e8f0ee14277d79a55ee63
  Reviewed-on: https://review.haiku-os.org/c/1005
  Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

f465c7fa619a: kits/midi2: Fix PVS 820
  
  Fix memory leak when realloc() fails.
  
  Change-Id: Ic787ca714e4a106cc22e6186078a8e72d0a0553d
  Reviewed-on: https://review.haiku-os.org/c/1006
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                      [ Murai Takashi <tmurai01@xxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 18 insertions(+), 5 deletions(-)
src/apps/mail/WIndex.cpp             | 9 +++++++--
src/kits/midi2/MidiLocalConsumer.cpp | 5 ++++-
src/kits/support/String.cpp          | 9 +++++++--

############################################################################

Commit:      6c67c7d635df087c1e32a83978d81617de4d245a
URL:         https://git.haiku-os.org/haiku/commit/?id=6c67c7d635df
Author:      Murai Takashi <tmurai01@xxxxxxxxx>
Date:        Fri Feb  1 11:31:43 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Feb  3 18:05:55 2019 UTC

support/String: Fix PVS 626

Fix memory leak when realloc() fails.

Change-Id: I5b44df57bdd251e5164938ed70412c909ce09df1
Reviewed-on: https://review.haiku-os.org/c/1004
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp
index 9bdfcbb280..2089d62960 100644
--- a/src/kits/support/String.cpp
+++ b/src/kits/support/String.cpp
@@ -2360,9 +2360,14 @@ BString::_Resize(int32 length)
        if (length < 0)
                length = 0;
 
-       data = (char*)realloc(data, length + kPrivateDataOffset + 1);
-       if (data == NULL)
+       char* newData = (char*)realloc(data, length + kPrivateDataOffset + 1);
+       if (newData == NULL) {
+               free(data);
+               data = NULL;
                return NULL;
+       } else {
+               data = newData;
+       }
 
        data += kPrivateDataOffset;
 

############################################################################

Commit:      21392fa9b1498f874aa688545b9e501a84c04812
URL:         https://git.haiku-os.org/haiku/commit/?id=21392fa9b149
Author:      Murai Takashi <tmurai01@xxxxxxxxx>
Date:        Fri Feb  1 11:29:58 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Feb  3 18:05:55 2019 UTC

mail: Fix PVS 965

Fix memory leak when realloc() fails.

Change-Id: I8f7fb3ce7f43de03f76e8f0ee14277d79a55ee63
Reviewed-on: https://review.haiku-os.org/c/1005
Reviewed-by: Adrien Destugues <pulkomandy@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/apps/mail/WIndex.cpp b/src/apps/mail/WIndex.cpp
index 9a39c52c16..76b38da4ba 100644
--- a/src/apps/mail/WIndex.cpp
+++ b/src/apps/mail/WIndex.cpp
@@ -268,9 +268,14 @@ WIndex::_BlockCheck(void)
        if (fEntries < fMaxEntries)
                return B_OK;
        fBlocks = fEntries / fEntriesPerBlock + 1;
-       fEntryList = (uint8 *)realloc(fEntryList, fBlockSize * fBlocks);
-       if (!fEntryList)
+       uint8* tmpEntryList = (uint8 *)realloc(fEntryList, fBlockSize * 
fBlocks);
+       if (!tmpEntryList) {
+               free(fEntryList);
+               fEntryList = NULL;
                return B_ERROR;
+       } else {
+               fEntryList = tmpEntryList;
+       }
        return B_OK;
 }
 

############################################################################

Revision:    hrev52836
Commit:      f465c7fa619a31eabf63b5e8d72edcdf78982c8e
URL:         https://git.haiku-os.org/haiku/commit/?id=f465c7fa619a
Author:      Murai Takashi <tmurai01@xxxxxxxxx>
Date:        Thu Jan 31 20:38:10 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Sun Feb  3 18:05:55 2019 UTC

kits/midi2: Fix PVS 820

Fix memory leak when realloc() fails.

Change-Id: Ic787ca714e4a106cc22e6186078a8e72d0a0553d
Reviewed-on: https://review.haiku-os.org/c/1006
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

----------------------------------------------------------------------------

diff --git a/src/kits/midi2/MidiLocalConsumer.cpp 
b/src/kits/midi2/MidiLocalConsumer.cpp
index 1ab05a5c1c..d661614982 100644
--- a/src/kits/midi2/MidiLocalConsumer.cpp
+++ b/src/kits/midi2/MidiLocalConsumer.cpp
@@ -345,7 +345,10 @@ BMidiLocalConsumer::EventThread()
                        break;  // error reading port
 
                if (msg_size > buf_size) {
-                       buffer = (uint8*) realloc(buffer, msg_size);
+                       uint8* tmp_buffer = (uint8*) realloc(buffer, msg_size);
+                       if (tmp_buffer == NULL)
+                               break; // error in realloc()
+                       buffer = tmp_buffer;
                        buf_size = msg_size;
                }
 


Other related posts:

  • » [haiku-commits] haiku: hrev52836 - in src: apps/mail kits/support kits/midi2 - waddlesplash