diff mbox series

[OpenWrt-Devel,1/6] uclient-fetch: Check for nullpointer returned by open_output_file

Message ID 20180218033640.17715-2-tobleminer@gmail.com
State Changes Requested
Delegated to: John Crispin
Headers show
Series uclient: Handle memory allocation failures | expand

Commit Message

Tobias Schramm Feb. 18, 2018, 3:36 a.m. UTC
Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
---
 uclient-fetch.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

John Crispin Feb. 18, 2018, 10:15 a.m. UTC | #1
On 18/02/18 04:36, Tobias Schramm wrote:
> Signed-off-by: Tobias Schramm <tobleminer@gmail.com>
> ---
>   uclient-fetch.c | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/uclient-fetch.c b/uclient-fetch.c
> index 6961d94..46f9b3d 100644
> --- a/uclient-fetch.c
> +++ b/uclient-fetch.c
> @@ -122,6 +122,11 @@ static int open_output_file(const char *path, uint64_t resume_offset)
>   		}
>   	} else {
>   		filename = uclient_get_url_filename(path, "index.html");
> +		if(!filename) {
> +			ret = -ENOMEM;
> +			goto done;

should this not be goto free; ?

     John

> +		}
> +
>   		output_file = filename;
>   	}
>
diff mbox series

Patch

diff --git a/uclient-fetch.c b/uclient-fetch.c
index 6961d94..46f9b3d 100644
--- a/uclient-fetch.c
+++ b/uclient-fetch.c
@@ -122,6 +122,11 @@  static int open_output_file(const char *path, uint64_t resume_offset)
 		}
 	} else {
 		filename = uclient_get_url_filename(path, "index.html");
+		if(!filename) {
+			ret = -ENOMEM;
+			goto done;
+		}
+
 		output_file = filename;
 	}