From dd778cd92b04e8f19ea5b0240f8d7aa75884e7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 17 Nov 2006 15:00:26 +0000 Subject: [PATCH] * Sending uninitialized buffers to Icon-O-Matic is sure fun, but it actually caused Icon-O-Matic to refuse to work with us :) * only call free() when the data has actually been allocated. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19318 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/filetypes/IconView.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/preferences/filetypes/IconView.cpp b/src/preferences/filetypes/IconView.cpp index 73d987b287..feb561d1f7 100644 --- a/src/preferences/filetypes/IconView.cpp +++ b/src/preferences/filetypes/IconView.cpp @@ -427,6 +427,7 @@ Icon::GetData(uint8** _data, size_t* _size) const if (data == NULL) return B_NO_MEMORY; + memcpy(data, fData, fSize); *_data = data; *_size = fSize; return B_OK; @@ -1149,17 +1150,18 @@ IconView::_AddOrEditIcon() if (icon->HasData()) { uint8* data; size_t size; - if (icon->GetData(&data, &size) == B_OK) + if (icon->GetData(&data, &size) == B_OK) { message.AddData("icon data", B_VECTOR_ICON_TYPE, data, size); + free(data); + } + // TODO: somehow figure out how names of objects in the icon // can be preserved. Maybe in a second (optional) attribute // where ever a vector icon attribute is present? - - free(data); } } - be_roster->Launch("application/x-vnd.Haiku-icon_o_matic", &message); + be_roster->Launch("application/x-vnd.haiku-icon_o_matic", &message); #endif }