Tracker: Fix dereference after NULL, CID 601541

_TrackerLaunchDocuments() dereferences refs to copy it, so, we need
check that it isn't NULL first.

Also a few style fixes.
* Name params consistent with TTracker class methods
  ref, message => appRef, refs
* Use NULL instead of 0 for NULL pointer.
This commit is contained in:
John Scipione 2014-07-18 19:12:29 -04:00
parent 58121655ed
commit ab28908d2d
2 changed files with 21 additions and 18 deletions

View File

@ -3474,9 +3474,12 @@ LoaderErrorDetails(const entry_ref* app, BString &details)
static void static void
_TrackerLaunchDocuments(const entry_ref* /*doNotUse*/, const BMessage* refs, _TrackerLaunchDocuments(const entry_ref*, const BMessage* refs,
bool openWithOK) bool openWithOK)
{ {
if (refs == NULL)
return;
BMessage copyOfRefs(*refs); BMessage copyOfRefs(*refs);
entry_ref documentRef; entry_ref documentRef;
@ -3700,7 +3703,7 @@ status_t
TrackerLaunch(const entry_ref* appRef, bool async) TrackerLaunch(const entry_ref* appRef, bool async)
{ {
if (!async) if (!async)
_TrackerLaunchAppWithDocuments(appRef, 0, false); _TrackerLaunchAppWithDocuments(appRef, NULL, false);
else else
AsynchLaunchBinder(&_TrackerLaunchAppWithDocuments, appRef, 0, false); AsynchLaunchBinder(&_TrackerLaunchAppWithDocuments, appRef, 0, false);
@ -3711,9 +3714,9 @@ status_t
TrackerLaunch(const BMessage* refs, bool async, bool openWithOK) TrackerLaunch(const BMessage* refs, bool async, bool openWithOK)
{ {
if (!async) if (!async)
_TrackerLaunchDocuments(0, refs, openWithOK); _TrackerLaunchDocuments(NULL, refs, openWithOK);
else else
AsynchLaunchBinder(&_TrackerLaunchDocuments, 0, refs, openWithOK); AsynchLaunchBinder(&_TrackerLaunchDocuments, NULL, refs, openWithOK);
return B_OK; return B_OK;
} }
@ -3787,22 +3790,22 @@ FSLaunchUsing(const entry_ref* ref, BMessage* listOfRefs)
status_t status_t
FSLaunchItem(const entry_ref* ref, BMessage* message, int32, bool async) FSLaunchItem(const entry_ref* appRef, BMessage* refs, int32, bool async)
{ {
if (message != NULL) if (refs != NULL)
message->what = B_REFS_RECEIVED; refs->what = B_REFS_RECEIVED;
status_t result = TrackerLaunch(ref, message, async, true); status_t result = TrackerLaunch(appRef, refs, async, true);
delete message; delete refs;
return result; return result;
} }
void void
FSLaunchItem(const entry_ref* ref, BMessage* message, int32 workspace) FSLaunchItem(const entry_ref* appRef, BMessage* refs, int32 workspace)
{ {
FSLaunchItem(ref, message, workspace, true); FSLaunchItem(appRef, refs, workspace, true);
} }

View File

@ -244,11 +244,11 @@ status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, entry_ref& _ref);
status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BEntry& _entry); status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BEntry& _entry);
status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BNode& _node); status_t FSGetParentVirtualDirectoryAware(const BEntry& entry, BNode& _node);
status_t TrackerLaunch(const entry_ref* app, bool async); status_t TrackerLaunch(const entry_ref* appRef, bool async);
status_t TrackerLaunch(const BMessage* refs, bool async, status_t TrackerLaunch(const BMessage* refs, bool async,
bool okToRunOpenWith = true); bool okToRunOpenWith = true);
status_t TrackerLaunch(const entry_ref* app, const BMessage* refs, bool async, status_t TrackerLaunch(const entry_ref* appRef, const BMessage* refs,
bool okToRunOpenWith = true); bool async, bool okToRunOpenWith = true);
status_t LaunchBrokenLink(const char*, const BMessage*); status_t LaunchBrokenLink(const char*, const BMessage*);
status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true); status_t FSFindTrackerSettingsDir(BPath*, bool autoCreate = true);
@ -266,10 +266,10 @@ bool ConfirmChangeIfWellKnownDirectory(const BEntry* entry,
bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel); bool CheckDevicesEqual(const entry_ref* entry, const Model* targetModel);
// Deprecated calls use newer calls above instead // Deprecated calls use newer calls above instead
_IMPEXP_TRACKER void FSLaunchItem(const entry_ref*, BMessage* = NULL, _IMPEXP_TRACKER void FSLaunchItem(const entry_ref* appRef,
int32 workspace = -1); BMessage* refs = NULL, int32 workspace = -1);
_IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref*, BMessage*, _IMPEXP_TRACKER status_t FSLaunchItem(const entry_ref* appRef,
int32 workspace, bool asynch); BMessage* refs, int32 workspace, bool asynch);
_IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch, _IMPEXP_TRACKER void FSOpenWithDocuments(const entry_ref* executableToLaunch,
BMessage* documentEntryRefs); BMessage* documentEntryRefs);
_IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref, _IMPEXP_TRACKER status_t FSLaunchUsing(const entry_ref* ref,