Skip to contentSkip to conversation

* lib/ext2fs/dosio.c (dos_open): don't leak strdup'd dev name upon error

PATCH Applied Jim Meyering 2 participants 2 messages Feb 23, 2009 – Mar 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 * lib/ext2fs/dosio.c (dos_open): don't leak strdup'd dev name upon error

---
Spotted by inspection.
For all I know, this is dead code ;-)

 lib/ext2fs/dosio.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
lib/ext2fs/dosio.c +3 -0
index 97ceef5..a7968cd 100644
@@ -278,6 +278,7 @@ static errcode_t dos_open(const char *dev, int flags, io_channel *channel)
   if(!HW_OK())
   {
     _dio_error = ERR_HARDWARE;
+    free(part->dev);
     free(part);
     return EFAULT;
   }
@@ -297,6 +298,7 @@ static errcode_t dos_open(const char *dev, int flags, io_channel *channel)
   if(!HW_OK())
   {
     _dio_error = ERR_HARDWARE;
+    free(part->dev);
     free(part);
     return EFAULT;
   }
@@ -308,6 +310,7 @@ static errcode_t dos_open(const char *dev, int flags, io_channel *channel)
   {
     _dio_error = part->pno == 0xFE ? ERR_EMPTYPART :
                  part->pno == 0xFD ? ERR_LINUXSWAP : ERR_NOTEXT2FS;
+    free(part->dev);
     free(part);
     return ENODEV;
   }

--
1.6.2.rc1.266.g4bdf