In easycsv_read_value, check if row and col are valid

Signed-off-by: Pradana AUMARS <paumars@courrier.dev>
This commit is contained in:
Pradana AUMARS 2021-07-17 13:36:09 +02:00
parent 46ed839860
commit 0793a5a1c6
1 changed files with 10 additions and 0 deletions

View File

@ -163,11 +163,21 @@ easycsv_read_value(const easycsv *csv,
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);