Skip to content

Commit

Permalink
Tracker: check result of FlattenedSize() for error
Browse files Browse the repository at this point in the history
  • Loading branch information
stpere committed Jul 3, 2015
1 parent a495c5e commit 189c10b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/kits/tracker/Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,14 @@ TTracker::QuitRequested()
if (!BootedInSafeMode() && FSGetDeskDir(&deskDir) == B_OK) {
// if message is empty, delete the corresponding attribute
if (message.CountNames(B_ANY_TYPE)) {
size_t size = (size_t)message.FlattenedSize();
char* buffer = new char[size];
message.Flatten(buffer, (ssize_t)size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
size);
delete[] buffer;
ssize_t size = message.FlattenedSize();
if (size > B_OK) {
char* buffer = new char[size];
message.Flatten(buffer, size);
deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer,
size);
delete[] buffer;
}
} else
deskDir.RemoveAttr(kAttrOpenWindows);
}
Expand Down

0 comments on commit 189c10b

Please sign in to comment.