From 0793a5a1c684fc9e9f32d5e8ad343a7424997eb8 Mon Sep 17 00:00:00 2001 From: Pradana AUMARS Date: Sat, 17 Jul 2021 13:36:09 +0200 Subject: [PATCH] In easycsv_read_value, check if row and col are valid Signed-off-by: Pradana AUMARS --- src/easycsv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/easycsv.c b/src/easycsv.c index d538ceb..371886f 100644 --- a/src/easycsv.c +++ b/src/easycsv.c @@ -162,12 +162,22 @@ easycsv_read_value(const easycsv *csv, easycsv_error(EASYCSV_ZEROROW, NULL); return NULL; } + + if (row > easycsv_print_rows(csv)) { + easycsv_error(EASYCSV_ROWNOTEXIST, NULL); + return NULL; + } if (col == 0) { easycsv_error(EASYCSV_ZEROCOL, NULL); return NULL; } + if (col > easycsv_print_columns(csv)) { + easycsv_error(EASYCSV_COLNOTEXIST, NULL); + return NULL; + } + /* Set file pointer to start */ easycsv_rewind(csv);