Print this page
10076 make usr/src/test smatch clean
@@ -26,10 +26,14 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
*/
+/*
+ * Copyright (c) 2018, Joyent, Inc.
+ */
+
#include "../file_common.h"
/*
* Create a file with assigned size and then free the specified
* section of the file
@@ -82,21 +86,24 @@
buf = (char *)malloc(filesize);
if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, mode)) < 0) {
perror("open");
+ free(buf);
return (1);
}
if (write(fd, buf, filesize) < filesize) {
perror("write");
+ free(buf);
return (1);
}
fl.l_whence = SEEK_SET;
fl.l_start = start_off;
fl.l_len = off_len;
if (fcntl(fd, F_FREESP, &fl) != 0) {
perror("fcntl");
+ free(buf);
return (1);
}
free(buf);
return (0);