diff mbox series

fwts_log_plaintext: check for null pointer

Message ID 20190610105419.15842-1-colin.king@canonical.com
State Accepted
Headers show
Series fwts_log_plaintext: check for null pointer | expand

Commit Message

Colin Ian King June 10, 2019, 10:54 a.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The pointer 'lines' can potentially be null, so check for this.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_log_plaintext.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Hung June 10, 2019, 8:29 p.m. UTC | #1
On 2019-06-10 3:54 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The pointer 'lines' can potentially be null, so check for this.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_log_plaintext.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/lib/src/fwts_log_plaintext.c b/src/lib/src/fwts_log_plaintext.c
> index 1151603e..a8cbfb53 100644
> --- a/src/lib/src/fwts_log_plaintext.c
> +++ b/src/lib/src/fwts_log_plaintext.c
> @@ -130,6 +130,8 @@ static int fwts_log_print_plaintext(
>  	else
>  		lines = fwts_format_text(tmpbuf + header_len, log_file->line_width - header_len);
>  
> +	if (!lines)
> +		return 0;
>  	len = n;
>  
>  	fwts_list_foreach(item, lines) {
> 

Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu June 11, 2019, 5:44 a.m. UTC | #2
On 6/10/19 6:54 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The pointer 'lines' can potentially be null, so check for this.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_log_plaintext.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/lib/src/fwts_log_plaintext.c b/src/lib/src/fwts_log_plaintext.c
> index 1151603e..a8cbfb53 100644
> --- a/src/lib/src/fwts_log_plaintext.c
> +++ b/src/lib/src/fwts_log_plaintext.c
> @@ -130,6 +130,8 @@ static int fwts_log_print_plaintext(
>  	else
>  		lines = fwts_format_text(tmpbuf + header_len, log_file->line_width - header_len);
>  
> +	if (!lines)
> +		return 0;
>  	len = n;
>  
>  	fwts_list_foreach(item, lines) {


Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_log_plaintext.c b/src/lib/src/fwts_log_plaintext.c
index 1151603e..a8cbfb53 100644
--- a/src/lib/src/fwts_log_plaintext.c
+++ b/src/lib/src/fwts_log_plaintext.c
@@ -130,6 +130,8 @@  static int fwts_log_print_plaintext(
 	else
 		lines = fwts_format_text(tmpbuf + header_len, log_file->line_width - header_len);
 
+	if (!lines)
+		return 0;
 	len = n;
 
 	fwts_list_foreach(item, lines) {