summaryrefslogtreecommitdiff
path: root/payloads/libpayload/curses
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2016-12-13 15:47:22 +0100
committerPatrick Georgi <pgeorgi@google.com>2016-12-14 15:58:22 +0100
commit83f75bfeb93194e1a41a7c69431f5249cc04b4e8 (patch)
treef0c83dc9d1c76d9a4a82686431dd82c03981b2a8 /payloads/libpayload/curses
parentcf3b306cafdb76493ff605c5dd05bbd602293147 (diff)
downloadcoreboot-83f75bfeb93194e1a41a7c69431f5249cc04b4e8.tar.xz
libpayload/.../PDCurses: avoid reading orig before NULL checking it
Coverity complains and that (unfortunately) means that some compiler might take advantage of the same fact. Change-Id: I59aff77820c524fa5a0fcb251c1268da475101fb Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Found-by: Coverity Scan #1261105 Reviewed-on: https://review.coreboot.org/17835 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'payloads/libpayload/curses')
-rw-r--r--payloads/libpayload/curses/PDCurses/pdcurses/window.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/payloads/libpayload/curses/PDCurses/pdcurses/window.c b/payloads/libpayload/curses/PDCurses/pdcurses/window.c
index b5634c7c37..24c5fd29d3 100644
--- a/payloads/libpayload/curses/PDCurses/pdcurses/window.c
+++ b/payloads/libpayload/curses/PDCurses/pdcurses/window.c
@@ -294,9 +294,7 @@ int mvwin(WINDOW *win, int y, int x)
WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
{
WINDOW *win;
- int i;
- int j = begy - orig->_begy;
- int k = begx - orig->_begx;
+ int i, j, k;
PDC_LOG(("subwin() - called: lines %d cols %d begy %d begx %d\n",
nlines, ncols, begy, begx));
@@ -308,6 +306,9 @@ WINDOW *subwin(WINDOW *orig, int nlines, int ncols, int begy, int begx)
(begx + ncols) > (orig->_begx + orig->_maxx))
return (WINDOW *)NULL;
+ j = begy - orig->_begy;
+ k = begx - orig->_begx;
+
if (!nlines)
nlines = orig->_maxy - 1 - j;
if (!ncols)