summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-04-11 09:20:24 +0300
committerTor Lillqvist <tml@iki.fi>2013-04-11 09:29:05 +0300
commitc744ff638f778e641ea7ee37d4700c946af5a45e (patch)
tree4fe79791820d8a9c1d4bf9b276e4ee6aa2c5fa63 /sd
parent8b1b67db259a5a930555882b44fcac8738f73ca4 (diff)
It's fine to delete a NULL pointer
Calling delete on a NULL pointer does nothing. Checking for non-NULL just clutters the code. Still, I wonder if this code has some issues with heap corruption and/or leaks. The pImagesLst->GetEntryData() calls just return a copy of the OUString pointers stored in some kind of list, right? So is it correct to call delete on the copy, but keep the pointer in the list intact, which thus then will be pointing to freed memory, won't it? Or will the code automatically work in such a way that all pointers in the list will be handled exactly once (and deleted)? Perhaps running this under valgrind would be a good idea. Change-Id: Ibf401cc44caaeea6bb46f38cd9851ac14b2d2545
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/dlg/PhotoAlbumDialog.cxx12
1 files changed, 4 insertions, 8 deletions
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index 1d36f38ae27d..374b30532097 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -179,8 +179,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
}
}
- if (pData)
- delete pData;
+ delete pData;
}
else if( sOpt == "1 image with title" )
{
@@ -222,8 +221,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
appendNewSlide(AUTOLAYOUT_ONLY_TEXT, xDrawPages);
}
}
- if (pData)
- delete pData;
+ delete pData;
}
else if( sOpt == "2 images" )
{
@@ -335,8 +333,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
}
}
- if (pData)
- delete pData;
+ delete pData;
}
else if( sOpt == "4 images" )
{
@@ -542,8 +539,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, CreateHdl)
xSlide->add(xShape);
}
}
- if (pData)
- delete pData;
+ delete pData;
}
else
{