diff --git a/src/xlsx_drone.c b/src/xlsx_drone.c index 3258ca4..b593213 100644 --- a/src/xlsx_drone.c +++ b/src/xlsx_drone.c @@ -761,6 +761,10 @@ static xlsx_cell_category get_related_category(const char *format_code, int form * - current_analyzed_index: the index pointing to a specific char of *format_code*. */ static xlsx_formatter get_formatter(const char *format_code, int current_analyzed_index) { + int length_format_code = (int)strlen(format_code); + if (current_analyzed_index >= length_format_code) + return XLSX_FORMATTER_UNKNOWN; + switch(format_code[current_analyzed_index]) { case 'm': case 'h': case 's': case 'y': case 'd': { // "[Red]" case @@ -829,6 +833,9 @@ static xlsx_formatter get_formatter(const char *format_code, int current_analyze if((++i == current_analyzed_index) && (!quotes_open)) { break; } + if(i >= length_format_code) { + return XLSX_FORMATTER_UNKNOWN; + } } }