Skip to content

Commit

Permalink
fix: avoid integer underflow on get context start line
Browse files Browse the repository at this point in the history
  • Loading branch information
Silva97 committed Jan 16, 2025
1 parent 02941cb commit 70fd9a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/error_handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "module.h"


#define MIN(a, b) (a < b ? a : b)
#define LBUFF_SIZE 127


Expand All @@ -23,7 +24,7 @@ _error_remove_line(module_t* module);
void
error_module_ctx(module_t* module, unsigned int line, unsigned int column, unsigned int length, const char* message)
{
unsigned int ctx_start_line = line - ERR_CTX_SIZE;
unsigned int ctx_start_line = MIN(line - ERR_CTX_SIZE, 0);
unsigned int ctx_end_line = line + ERR_CTX_SIZE;
unsigned int current_line = 0;

Expand Down

0 comments on commit 70fd9a8

Please sign in to comment.