0

Hello guys i keep getting a

Unhandled exception at 0x7c177ac0 (mfc71d.dll) in LSMUtility.exe: 0xC0000005: Access violation reading location 0xcdcdcdbd.

However according to MSDN the code is right:

void CTemp::OnDelete()
{
	// TODO: Add your control notification handler code here
	CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
	
	if(pos != main_dlg->BTList.GetTailPosition())
	{
		main_dlg->BTList.RemoveAt(pos);
		MessageBox("deleted");
	}
}

the above code works and the error only occurs if itterate through the list by using Next and Back buttons and functions:

void  CTemp::OnNext()
{
	// TODO: Add your control notification handler code here
		CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
		if(pos != main_dlg->BTList.GetTailPosition())
	{
		 main_dlg->BTList.GetNext(pos);
		Display();
	}
	else
		MessageBox("end");
}

//and Pervious

void CTemp::OnPervious()
{
	// TODO: Add your control notification handler code here
	CLSMUtilityDlg *main_dlg = (CLSMUtilityDlg *) GetParent();
	if(pos != main_dlg->BTList.GetHeadPosition())
	{
		 main_dlg->BTList.GetPrev(pos);
		Display();
	}
	else

		MessageBox("At beginning");
}

Can anyone suggest where i've gone wrong please?

Thanks

2
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by Acidburn
0
Access violation reading location 0xcdcdcdbd.

Isn't that how uninitialized memory is filled in debug mode?

I think so, but I'm not sure how to fix it, it would appear that when i delete an object from the list, it gets deleted, but if i click pervious that works but then if i delete that and click 'next' i get that error.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.