From 9dec848f8db2e3c2c8d58b3798f325f3b9993a29 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 24 May 2008 15:36:25 +0000 Subject: [PATCH] Fixed memory leak. Discovered by Coverity (CID 1013). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25639 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/registrar/TRoster.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp index 293c2d3979..2c3c2733df 100644 --- a/src/servers/registrar/TRoster.cpp +++ b/src/servers/registrar/TRoster.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2007, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2001-2008, Ingo Weinhold, bonefish@users.sf.net. * Distributed under the terms of the MIT License. */ @@ -1810,7 +1810,9 @@ TRoster::_LoadRosterSettings(const char *path) off_t size; if (!error) error = file.GetSize(&size); - char *data; + + char *data = NULL; + if (!error) { data = new(nothrow) char[size]; error = data ? B_OK : B_NO_MEMORY; @@ -1821,6 +1823,9 @@ TRoster::_LoadRosterSettings(const char *path) } if (!error) error = stream.SetTo(std::string(data)); + + delete[] data; + if (!error) { // Clear the current lists as // we'll be manually building them up