Author: marcel Date: Wed May 21 17:34:50 2014 New Revision: 266509 URL: http://svnweb.freebsd.org/changeset/base/266509
Log: Fix CID 1215129: move the call to lseek(2) before the call to malloc(3) so that the error path (taken due to lseek(2) failing) isn't leaking memory. Modified: head/usr.bin/mkimg/image.c Modified: head/usr.bin/mkimg/image.c ============================================================================== --- head/usr.bin/mkimg/image.c Wed May 21 17:22:41 2014 (r266508) +++ head/usr.bin/mkimg/image.c Wed May 21 17:34:50 2014 (r266509) @@ -98,11 +98,11 @@ image_copyout(int fd) ofs = lseek(fd, 0L, SEEK_CUR); + if (lseek(image_fd, 0, SEEK_SET) != 0) + return (errno); buffer = malloc(BUFFER_SIZE); if (buffer == NULL) return (errno); - if (lseek(image_fd, 0, SEEK_SET) != 0) - return (errno); error = 0; while (1) { rdsz = read(image_fd, buffer, BUFFER_SIZE); _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"