Message ID | 20190610105419.15842-1-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | fwts_log_plaintext: check for null pointer | expand |
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>
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 --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) {