[haiku-commits] Re: r40634 - haiku/trunk/src/apps/deskcalc

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 23 Feb 2011 09:59:59 +0100

On 23.02.2011 03:08, stpere@xxxxxxxxx wrote:
Author: stpere
Date: 2011-02-23 03:08:03 +0100 (Wed, 23 Feb 2011)
New Revision: 40634
Changeset: http://dev.haiku-os.org/changeset/40634

Modified:
    haiku/trunk/src/apps/deskcalc/CalcView.cpp
Log:
DeskCalc:
  * Replace usage of strcpy by strlcpy (CID 6790)
  * Check the return value of FindApp before continuing (CID 2366)

[...]

@@ -1181,9 +1181,12 @@
  CalcView::_FetchAppIcon(BBitmap* into)
  {
        entry_ref appRef;
-       be_roster->FindApp(kAppSig,&appRef);
-       BFile file(&appRef, B_READ_ONLY);
-       BAppFileInfo appInfo(&file);
-       if (appInfo.GetIcon(into, B_MINI_ICON) != B_OK)
+       status_t status = be_roster->FindApp(kAppSig,&appRef);
+       if (status == B_OK) {
+               BFile file(&appRef, B_READ_ONLY);
+               BAppFileInfo appInfo(&file);
+               status = appInfo.GetIcon(into, B_MINI_ICON);
+       }
+       if (status != B_OK)
                memset(into->Bits(), 0, into->BitsLength());
  }

Checking the return code of FindApp() shouldn't really be necessary, since the error should carry over to appInfo.GetIcon() anyway (invalid file). Not reverting the change would be perfectly fine of course. :-)

Best regards,
-Stephan

Other related posts: