Ignore:
Timestamp:
2016-04-25T08:14:01Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6f2c1ff
Parents:
38ad239
git-author:
Manuele Conti <conti.manuele@…> (2016-04-25 08:14:01)
git-committer:
Jakub Jermar <jakub@…> (2016-04-25 08:14:01)
Message:

bdsh: Close fd and free buffer in error paths

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r38ad239 rbc41f3a3  
    165165                const char byte = 0x00;
    166166
    167                 if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0)
     167                if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) {
     168                        close(fd);
    168169                        goto error;
     170                }
    169171
    170172                rc2 = write(fd, &byte, sizeof(char));
    171                 if (rc2 < 0)
     173                if (rc2 < 0) {
     174                        close(fd);
    172175                        goto error;
     176                }
    173177                return CMD_SUCCESS;
    174178        }
     
    187191                        printf("%s: Error writing file (%d).\n", cmdname, errno);
    188192                        close(fd);
     193                        free(buffer);
    189194                        return CMD_FAILURE;
    190195                }
Note: See TracChangeset for help on using the changeset viewer.