IconSaver: fix potential memory leak
delete icon doesn’t do anything, delete[] data does.
This commit is contained in:
@@ -197,16 +197,24 @@ IconsSaver::_GetVectorIcons()
|
|||||||
if (mimeType.InitCheck() != B_OK)
|
if (mimeType.InitCheck() != B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vector_icon* icon = (vector_icon*)malloc(sizeof(vector_icon));
|
uint8* data;
|
||||||
if (icon == NULL)
|
size_t size;
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mimeType.GetIcon(&icon->data, &icon->size) != B_OK) {
|
if (mimeType.GetIcon(&data, &size) != B_OK) {
|
||||||
// didn't find an icon, delete the icon container
|
// didn't find an icon
|
||||||
delete icon;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector_icon* icon = (vector_icon*)malloc(sizeof(vector_icon));
|
||||||
|
if (icon == NULL) {
|
||||||
|
// ran out of memory, delete the icon data
|
||||||
|
delete[] data;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon->data = data;
|
||||||
|
icon->size = size;
|
||||||
|
|
||||||
// found a vector icon, add it to the list
|
// found a vector icon, add it to the list
|
||||||
fVectorIcons.AddItem(icon);
|
fVectorIcons.AddItem(icon);
|
||||||
if (fVectorIcons.CountItems() >= kMaxIconCount) {
|
if (fVectorIcons.CountItems() >= kMaxIconCount) {
|
||||||
|
|||||||
Reference in New Issue
Block a user