[haiku-commits] haiku: hrev49026 - src/kits/translation src/apps/aboutsystem build/jam/packages src/preferences/shortcuts

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 11 Apr 2015 15:13:59 +0200 (CEST)

hrev49026 adds 4 changesets to branch 'master'
old head: 459e651fd518aaecda9ff6079ea0385456e0be5b
new head: 9ac1c4c25e7e235c87962006fe614cda8bd8f193
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=9ac1c4c25e7e+%5E459e651fd518

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

268bbb1f8cae: AboutSystem: Fix leak of package credits.

827f11e9866b: Whitespace cleanup only.

abed891d1ba9: Shortcuts: Fix use-after-free in EditWindow return.

Calling Quit() on the window deletes it, so using the fTextControl
member to get the result does not work.

9ac1c4c25e7e: libicon: Fix leak of Icon::Gradient.

This was most prominently visible in applications that show a lot of
icons like Tracker and Deskbar.

[ Michael Lotz <mmlr@xxxxxxxx> ]

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

5 files changed, 55 insertions(+), 46 deletions(-)
build/jam/packages/Haiku | 2 +-
src/apps/aboutsystem/AboutSystem.cpp | 6 ++
src/kits/translation/TranslationUtils.cpp | 88 +++++++++++++--------------
src/libs/icon/style/Style.cpp | 1 +
src/preferences/shortcuts/EditWindow.cpp | 4 +-

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

Commit: 268bbb1f8cae24bea1709e7fa9903baf29da318b
URL: http://cgit.haiku-os.org/haiku/commit/?id=268bbb1f8cae
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 11:34:30 2015 UTC

AboutSystem: Fix leak of package credits.

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

diff --git a/src/apps/aboutsystem/AboutSystem.cpp
b/src/apps/aboutsystem/AboutSystem.cpp
index 8f08274..00483dc 100644
--- a/src/apps/aboutsystem/AboutSystem.cpp
+++ b/src/apps/aboutsystem/AboutSystem.cpp
@@ -592,6 +592,12 @@ AboutView::AboutView()

AboutView::~AboutView()
{
+ for (PackageCreditMap::iterator it = fPackageCredits.begin();
+ it != fPackageCredits.end(); it++) {
+
+ delete it->second;
+ }
+
delete fScrollRunner;
}


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

Commit: 827f11e9866b2a40c592389529045ba7166607ad
URL: http://cgit.haiku-os.org/haiku/commit/?id=827f11e9866b
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 11:37:28 2015 UTC

Whitespace cleanup only.

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

diff --git a/build/jam/packages/Haiku b/build/jam/packages/Haiku
index be3668d..c56729b 100644
--- a/build/jam/packages/Haiku
+++ b/build/jam/packages/Haiku
@@ -111,7 +111,7 @@ AddSymlinkToPackage lib : libbe.so : liblocale.so ;
AddFilesToPackage servers : $(SYSTEM_SERVERS) ;

# apps
-AddFilesToPackage : runtime_loader Deskbar
Tracker ;
+AddFilesToPackage : runtime_loader Deskbar
Tracker ;
AddFilesToPackage bin : $(SYSTEM_BIN) consoled ;
AddFilesToPackage apps : $(SYSTEM_APPS) ;
AddFilesToPackage preferences : $(SYSTEM_PREFERENCES) ;
diff --git a/src/kits/translation/TranslationUtils.cpp
b/src/kits/translation/TranslationUtils.cpp
index b8dc274..3e7383e 100644
--- a/src/kits/translation/TranslationUtils.cpp
+++ b/src/kits/translation/TranslationUtils.cpp
@@ -68,7 +68,7 @@ BTranslationUtils::operator=(const BTranslationUtils &kUtils)
//
// Preconditions:
//
-// Parameters: kName, the name of the bitmap file or resource to
+// Parameters: kName, the name of the bitmap file or resource to
// be returned
// roster, BTranslatorRoster used to do the translation
//
@@ -84,11 +84,11 @@ BTranslationUtils::GetBitmap(const char *kName,
BTranslatorRoster *roster)
{
BBitmap *pBitmap = GetBitmapFile(kName, roster);
// Try loading a bitmap from the file named name
-
+
// Try loading the bitmap as an application resource
if (pBitmap == NULL)
pBitmap = GetBitmap(B_TRANSLATOR_BITMAP, kName, roster);
-
+
return pBitmap;
}

@@ -96,7 +96,7 @@ BTranslationUtils::GetBitmap(const char *kName,
BTranslatorRoster *roster)
// GetBitmap
//
// Returns a BBitmap object for the bitmap resource identified by
-// the type type with the resource id, id.
+// the type type with the resource id, id.
// The user has to delete this object.
//
// Preconditions:
@@ -119,20 +119,20 @@ BTranslationUtils::GetBitmap(uint32 type, int32 id,
BTranslatorRoster *roster)
// it belongs to the application
if (pResources == NULL || pResources->HasResource(type, id) == false)
return NULL;
-
- // Load the bitmap resource from the application file
+
+ // Load the bitmap resource from the application file
// pRawData should be NULL if the resource is an
// unknown type or not available
size_t bitmapSize = 0;
const void *kpRawData = pResources->LoadResource(type, id, &bitmapSize);
if (kpRawData == NULL || bitmapSize == 0)
return NULL;
-
+
BMemoryIO memio(kpRawData, bitmapSize);
// Put the pointer to the raw image data into a BMemoryIO object
// so that it can be used with BTranslatorRoster->Translate() in
// the GetBitmap(BPositionIO *, BTranslatorRoster *) function
-
+
return GetBitmap(&memio, roster);
// Translate the data in memio using the BTranslatorRoster
roster
}
@@ -141,7 +141,7 @@ BTranslationUtils::GetBitmap(uint32 type, int32 id,
BTranslatorRoster *roster)
// GetBitmap
//
// Returns a BBitmap object for the bitmap resource identified by
-// the type type with the resource name, kName.
+// the type type with the resource name, kName.
// The user has to delete this object. Note that a resource type
// and name does not uniquely identify a resource in a file.
//
@@ -166,17 +166,17 @@ BTranslationUtils::GetBitmap(uint32 type, const char
*kName,
// it belongs to the application
if (pResources == NULL || pResources->HasResource(type, kName) == false)
return NULL;
-
- // Load the bitmap resource from the application file
+
+ // Load the bitmap resource from the application file
size_t bitmapSize = 0;
const void *kpRawData = pResources->LoadResource(type, kName,
&bitmapSize);
if (kpRawData == NULL || bitmapSize == 0)
return NULL;
-
+
BMemoryIO memio(kpRawData, bitmapSize);
// Put the pointer to the raw image data into a BMemoryIO
object so
- // that it can be used with BTranslatorRoster->Translate()
-
+ // that it can be used with BTranslatorRoster->Translate()
+
return GetBitmap(&memio, roster);
// Translate the data in memio using the BTranslatorRoster
roster
}
@@ -203,7 +203,7 @@ BTranslationUtils::GetBitmapFile(const char *kName,
BTranslatorRoster *roster)
{
if (!be_app || !kName || kName[0] == '\0')
return NULL;
-
+
BPath path;
if (kName[0] != '/') {
// If kName is a relative path, use the path of the
application's
@@ -221,7 +221,7 @@ BTranslationUtils::GetBitmapFile(const char *kName,
BTranslatorRoster *roster)

} else if (path.SetTo(kName) != B_OK)
return NULL;
-
+
BFile bitmapFile(path.Path(), B_READ_ONLY);
if (bitmapFile.InitCheck() != B_OK)
return NULL;
@@ -281,8 +281,8 @@ BTranslationUtils::GetBitmap(BPositionIO *stream,
BTranslatorRoster *roster)
{
if (stream == NULL)
return NULL;
-
- // Use default Translator if none is specified
+
+ // Use default Translator if none is specified
if (roster == NULL) {
roster = BTranslatorRoster::Default();
if (roster == NULL)
@@ -295,7 +295,7 @@ BTranslationUtils::GetBitmap(BPositionIO *stream,
BTranslatorRoster *roster)
if (roster->Translate(stream, NULL, NULL, &bitmapStream,
B_TRANSLATOR_BITMAP) < B_OK)
return NULL;
-
+
// Detach the BBitmap from the BBitmapStream so the user
// of this function can do what they please with it.
BBitmap *pBitmap = NULL;
@@ -307,13 +307,13 @@ BTranslationUtils::GetBitmap(BPositionIO *stream,
BTranslatorRoster *roster)


/*!
- This function translates the styled text in fromStream and
+ This function translates the styled text in fromStream and
inserts it at the end of the text in intoView, using the
BTranslatorRoster *roster to do the translation. The structs
that make it possible to work with the translated data are
defined in
/boot/develop/headers/be/translation/TranslatorFormats.h
-
+
\param source the stream with the styled text
\param intoView the view where the test will be inserted
roster, BTranslatorRoster used to do the translation
@@ -330,7 +330,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source,
BTextView* intoView,
if (source == NULL || intoView == NULL)
return B_BAD_VALUE;

- // Use default Translator if none is specified
+ // Use default Translator if none is specified
if (roster == NULL) {
roster = BTranslatorRoster::Default();
if (roster == NULL)
@@ -374,7 +374,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source,
BTextView* intoView,
if (mallocIO.BufferLength() < offset + kTextHeaderSize)
return B_BAD_DATA;

- TranslatorStyledTextTextHeader textHeader =
+ TranslatorStyledTextTextHeader textHeader =
*(const TranslatorStyledTextTextHeader *)(buffer + offset);

// convert the stm_header.header struct to the host format
@@ -402,7 +402,7 @@ BTranslationUtils::GetStyledText(BPositionIO* source,
BTextView* intoView,
const size_t kStyleHeaderSize =
sizeof(TranslatorStyledTextStyleHeader);
if (mallocIO.BufferLength() >= offset + kStyleHeaderSize) {
- TranslatorStyledTextStyleHeader styleHeader =
+ TranslatorStyledTextStyleHeader styleHeader =
*(reinterpret_cast<const
TranslatorStyledTextStyleHeader *>(buffer + offset));
swap_data(B_UINT32_TYPE, &styleHeader.header,
kRecordHeaderSize, B_SWAP_BENDIAN_TO_HOST);
swap_data(B_UINT32_TYPE, &styleHeader.apply_offset,
sizeof(uint32), B_SWAP_BENDIAN_TO_HOST);
@@ -452,11 +452,11 @@ BTranslationUtils::GetStyledText(BPositionIO* source,
BTextView* intoView,
plain text data to the file, but puts the styled text data in
the "styles" attribute. In other words, this function writes
styled text data to files in a manner that isn't human readable.
-
+
So, if you want to write styled text
data to a file, and you want it to behave the way StyledEdit does,
you want to use the BTranslationUtils::WriteStyledEditFile() function.
-
+
\param fromView, the view with the styled text in it
\param intoStream, the stream where the styled text is put
roster, not used
@@ -471,20 +471,20 @@ BTranslationUtils::PutStyledText(BTextView *fromView,
BPositionIO *intoStream,
{
if (fromView == NULL || intoStream == NULL)
return B_BAD_VALUE;
-
+
int32 textLength = fromView->TextLength();
if (textLength < 0)
return B_ERROR;
-
+
const char *pTextData = fromView->Text();
// its OK if the result of fromView->Text() is NULL
-
+
int32 runArrayLength = 0;
text_run_array *runArray = fromView->RunArray(0, textLength,
&runArrayLength);
if (runArray == NULL)
return B_ERROR;
-
+
int32 flatRunArrayLength = 0;
void *pflatRunArray =
BTextView::FlattenRunArray(runArray, &flatRunArrayLength);
@@ -496,13 +496,13 @@ BTranslationUtils::PutStyledText(BTextView *fromView,
BPositionIO *intoStream,
#endif
return B_ERROR;
}
-
+
// Rather than use a goto, I put a whole bunch of code that
// could error out inside of a loop, and break out of the loop
- // if there is an error.
+ // if there is an error.

// This block of code is where I do all of the writing of the
- // data to the stream. I've gathered all of the data that I
+ // data to the stream. I've gathered all of the data that I
// need at this point.
bool ok = false;
while (!ok) {
@@ -513,7 +513,7 @@ BTranslationUtils::PutStyledText(BTextView *fromView,
BPositionIO *intoStream,
stm_header.header.header_size = kStreamHeaderSize;
stm_header.header.data_size = 0;
stm_header.version = 100;
-
+
// convert the stm_header.header struct to the host format
const size_t kRecordHeaderSize =
sizeof(TranslatorStyledTextRecordHeader);
@@ -631,7 +631,7 @@ BTranslationUtils::WriteStyledEditFile(BTextView* view,
BFile* file, const char
// move to the start of the file if not already there
status_t status = file->Seek(0, SEEK_SET);
if (status != B_OK)
- return status;
+ return status;

const BCharacterSet* characterSet = NULL;
if (encoding != NULL && strcmp(encoding, ""))
@@ -760,17 +760,17 @@ BMessage *
BTranslationUtils::GetDefaultSettings(translator_id forTranslator,
BTranslatorRoster *roster)
{
- // Use default Translator if none is specified
+ // Use default Translator if none is specified
if (roster == NULL) {
roster = BTranslatorRoster::Default();
if (roster == NULL)
return NULL;
}
-
+
BMessage *message = new BMessage();
if (message == NULL)
return NULL;
-
+
status_t result = roster->GetConfigurationMessage(forTranslator,
message);
if (result != B_OK && result != B_NO_TRANSLATOR) {
// Be's version seems to just pass an empty BMessage
@@ -786,7 +786,7 @@ BTranslationUtils::GetDefaultSettings(translator_id
forTranslator,
// ---------------------------------------------------------------
// GetDefaultSettings
//
-// Attempts to find the translator settings for
+// Attempts to find the translator settings for
// the translator named kTranslatorName with a version of
// translatorVersion.
//
@@ -827,11 +827,11 @@ BTranslationUtils::GetDefaultSettings(const char
*kTranslatorName,
if (currentTranVersion == translatorVersion
&& strcmp(currentTranName, kTranslatorName) ==
0) {
pMessage = GetDefaultSettings(translators[i],
roster);
- break;
+ break;
}
}
}
-
+
delete[] translators;
return pMessage;
}
@@ -864,7 +864,7 @@ BTranslationUtils::GetDefaultSettings(const char
*kTranslatorName,
// output format id in the menuitem
// roster, BTranslatorRoster used to find translators
// if NULL, the default translators are used
-//
+//
//
// Postconditions:
//
@@ -879,7 +879,7 @@ BTranslationUtils::AddTranslationItems(BMenu *intoMenu,
uint32 fromType,
{
if (!intoMenu)
return B_BAD_VALUE;
-
+
if (!roster)
roster = BTranslatorRoster::Default();

@@ -914,7 +914,7 @@ BTranslationUtils::AddTranslationItems(BMenu *intoMenu,
uint32 fromType,
continue;

// Get supported output formats
- err = roster->GetOutputFormats(ids[tix], &formats,
&numFormats);
+ err = roster->GetOutputFormats(ids[tix], &formats, &numFormats);
if (err == B_OK) {
for (int oix = 0; oix < numFormats; oix++) {
if (formats[oix].type != fromType) {

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

Commit: abed891d1ba9b4410d916bf4cc5daa4233b7072e
URL: http://cgit.haiku-os.org/haiku/commit/?id=abed891d1ba9
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 11:39:33 2015 UTC

Shortcuts: Fix use-after-free in EditWindow return.

Calling Quit() on the window deletes it, so using the fTextControl
member to get the result does not work.

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

diff --git a/src/preferences/shortcuts/EditWindow.cpp
b/src/preferences/shortcuts/EditWindow.cpp
index e2e08a6..04c8f7a 100644
--- a/src/preferences/shortcuts/EditWindow.cpp
+++ b/src/preferences/shortcuts/EditWindow.cpp
@@ -68,7 +68,9 @@ EditWindow::Go()
CenterOnScreen();

acquire_sem(fSem);
+ BString result = fTextControl->Text();
if (Lock())
Quit();
- return fTextControl->Text();
+
+ return result;
}

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

Revision: hrev49026
Commit: 9ac1c4c25e7e235c87962006fe614cda8bd8f193
URL: http://cgit.haiku-os.org/haiku/commit/?id=9ac1c4c25e7e
Author: Michael Lotz <mmlr@xxxxxxxx>
Date: Sat Apr 11 12:55:11 2015 UTC

libicon: Fix leak of Icon::Gradient.

This was most prominently visible in applications that show a lot of
icons like Tracker and Deskbar.

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

diff --git a/src/libs/icon/style/Style.cpp b/src/libs/icon/style/Style.cpp
index 8146203..3b621ba 100644
--- a/src/libs/icon/style/Style.cpp
+++ b/src/libs/icon/style/Style.cpp
@@ -223,6 +223,7 @@ Style::SetGradient(const ::Gradient* gradient)
#endif
delete[] fColors;
delete[] fGammaCorrectedColors;
+ delete fGradient;
fColors = NULL;
fGammaCorrectedColors = NULL;
fGradient = NULL;


Other related posts:

  • » [haiku-commits] haiku: hrev49026 - src/kits/translation src/apps/aboutsystem build/jam/packages src/preferences/shortcuts - mmlr