[haiku-commits] Re: r38174 - haiku/trunk/src/apps/icon-o-matic/import_export/styled_text

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 17 Aug 2010 11:26:00 +0200

Am 17.08.2010 10:05, schrieb pulkomandy@xxxxxxxxxxxxxxxxx:
Author: pulkomandy
Date: 2010-08-17 10:05:12 +0200 (Tue, 17 Aug 2010)
New Revision: 38174
Changeset: http://dev.haiku-os.org/changeset/38174

Modified:
    
haiku/trunk/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp
Log:
CID 1396: NULL pointer dereference.


Modified: 
haiku/trunk/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp
===================================================================
--- 
haiku/trunk/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp
  2010-08-17 07:53:58 UTC (rev 38173)
+++ 
haiku/trunk/src/apps/icon-o-matic/import_export/styled_text/StyledTextImporter.cpp
  2010-08-17 08:05:12 UTC (rev 38174)
@@ -320,8 +320,10 @@
                        //offset.x += glyph.Bounds().Width();
                        offset.x += charWidth;
                        Shape* shape = new (nothrow) Shape(NULL);
+                       if (shape == NULL)
+                               return B_NO_MEMORY;
                        shape->SetName(glyphName.String());
-                       if (!shape || !icon->Shapes()->AddShape(shape)) {
+                       if (!icon->Shapes()->AddShape(shape)) {
                                delete shape;
                                return B_NO_MEMORY;
                        }

The simpler fix would have been to move the SetName() line below the existing checks. :-)

Best regards,
-Stephan


Other related posts: