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

View File

@ -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);