Skip to content
Snippets Groups Projects
Commit 0ece2290 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Fix crashes when remove items from the failed login list

We need to get the NextItem *before* we delete the current one.

I'm not sure why this was in there, but removed it as appears to have
no effect:
	if(ListView->Selected == NULL)
		break;
parent 3af564a2
No related branches found
No related tags found
No related merge requests found
Pipeline #5054 passed
...@@ -119,7 +119,7 @@ void __fastcall TLoginAttemptsForm::ListViewCompare(TObject *Sender, ...@@ -119,7 +119,7 @@ void __fastcall TLoginAttemptsForm::ListViewCompare(TObject *Sender,
/* Decimal compare */ /* Decimal compare */
if (ColumnToSort < 2 || ColumnToSort == 6) { if (ColumnToSort < 2 || ColumnToSort == 6) {
int num1, num2; int num1, num2;
if(ColumnToSort==6) { /* Date */ if(ColumnToSort==6 && Item1->Data && Item2->Data) { /* Date */
num1 = ((login_attempt_t*)Item1->Data)->time; num1 = ((login_attempt_t*)Item1->Data)->time;
num2 = ((login_attempt_t*)Item2->Data)->time; num2 = ((login_attempt_t*)Item2->Data)->time;
} else if(ColumnToSort==0) { } else if(ColumnToSort==0) {
...@@ -205,10 +205,7 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -205,10 +205,7 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
ListView->Items->BeginUpdate(); ListView->Items->BeginUpdate();
while(ListItem!=NULL) { while(ListItem!=NULL) {
TListItem* NextItem = ListView->GetNextItem(ListItem,sdAll,State);
struct in_addr addr;
HOSTENT* h;
AnsiString ip_addr = ListItem->SubItems->Strings[1]; AnsiString ip_addr = ListItem->SubItems->Strings[1];
if(!repeat) { if(!repeat) {
Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm); Application->CreateForm(__classid(TCodeInputForm), &CodeInputForm);
...@@ -241,8 +238,9 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -241,8 +238,9 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
login_attempt_t* attempt = (login_attempt_t*)ListItem->Data; login_attempt_t* attempt = (login_attempt_t*)ListItem->Data;
if(attempt != NULL) { if(attempt != NULL) {
char* hostname = NULL; char* hostname = NULL;
struct in_addr addr = {};
addr.s_addr = inet_addr(ip_addr.c_str()); addr.s_addr = inet_addr(ip_addr.c_str());
h=gethostbyaddr((char *)&addr,sizeof(addr),AF_INET); HOSTENT* h = gethostbyaddr((char *)&addr,sizeof(addr),AF_INET);
if(h!=NULL) if(h!=NULL)
hostname = h->h_name; hostname = h->h_name;
char tmp[128]; char tmp[128];
...@@ -256,9 +254,7 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender) ...@@ -256,9 +254,7 @@ void __fastcall TLoginAttemptsForm::FilterIpMenuItemClick(TObject *Sender)
ListItem->Delete(); ListItem->Delete();
} }
} }
if(ListView->Selected == NULL) ListItem = NextItem;
break;
ListItem=ListView->GetNextItem(ListItem,sdAll,State);
} }
ListView->Items->EndUpdate(); ListView->Items->EndUpdate();
Screen->Cursor=crDefault; Screen->Cursor=crDefault;
...@@ -327,12 +323,13 @@ void __fastcall TLoginAttemptsForm::Remove1Click(TObject *Sender) ...@@ -327,12 +323,13 @@ void __fastcall TLoginAttemptsForm::Remove1Click(TObject *Sender)
ListView->Items->BeginUpdate(); ListView->Items->BeginUpdate();
while (ListItem != NULL) { while (ListItem != NULL) {
TListItem* NextItem = ListView->GetNextItem(ListItem, sdAll, State);
login_attempt_t* attempt = (login_attempt_t*)ListItem->Data; login_attempt_t* attempt = (login_attempt_t*)ListItem->Data;
if(attempt != NULL) { if(attempt != NULL) {
loginSuccess(&login_attempt_list, &attempt->addr); loginSuccess(&login_attempt_list, &attempt->addr);
ListItem->Delete(); ListItem->Delete();
} }
ListItem=ListView->GetNextItem(ListItem, sdAll, State); ListItem = NextItem;
} }
ListView->Items->EndUpdate(); ListView->Items->EndUpdate();
Screen->Cursor=crDefault; Screen->Cursor=crDefault;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment