lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 25 Apr 2023 13:04:27 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Hao Zeng <zenghao@...inos.cn>
Cc:     chenhuacai@...nel.org, zhangqing@...ngson.cn,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] recordmcount: Fix memory leaks in the uwrite
 function

On Tue, 25 Apr 2023 10:46:03 +0800
Hao Zeng <zenghao@...inos.cn> wrote:

> @@ -117,7 +118,13 @@ static ssize_t uwrite(void const *const buf, size_t const count)
>  		off_t aoffset = (file_ptr + count) - file_end;
>  
>  		if (aoffset > file_append_size) {
> -			file_append = realloc(file_append, aoffset);
> +			p = realloc(file_append, aoffset);
> +			if (!p) {
> +				free(file_append);
> +				file_append = NULL;
> +			} else {
> +				file_append = p;
> +			}

You can simplify the above with:

			if (!p)
				free(file_append);

			file_append = p;

-- Steve

>  			file_append_size = aoffset;
>  		}
>  		if (!file_append) {

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ