Hello
Could anybody help me?
I have the following piece of code -
-
cryptReturnVal = new BYTE[len];
-
char *cryptReturnValueChar;
-
-
// call decrypt function
-
cryptReturnVal=(*decrypt)(input, len, secretKey, ecretKeySize);
-
-
// convert result in hexadecimal format
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);
-
-
m_editOutput.SetWindowText(cryptReturnValueChar);
-
-
// free memory
-
delete [] cryptReturnVal;
-
delete cryptReturnValueChar;
-
-
When i'm trying to free the dynamically allocated memory, my application crashes and i get the following message " User breakpoint called from code at 0x******". I think this means that some access violation occurs, but i don't understand why
10 8752
Hello
Could anybody help me?
I have the following piece of code -
-
cryptReturnVal = new BYTE[len];//gpraghuram -- if u are allocating memory , then
-
char *cryptReturnValueChar;
-
-
// call decrypt function
-
cryptReturnVal=(*decrypt)(input, len, secretKey, ecretKeySize);//gpraghuram--the memory gets overwritten here.[/b]
-
-
// convert result in hexadecimal format
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);
-
-
m_editOutput.SetWindowText(cryptReturnValueChar);
-
-
// free memory
-
delete [] cryptReturnVal;
-
delete cryptReturnValueChar; // gpraghuram does the memory is allocated to this properly?
-
-
When i'm trying to free the dynamically allocated memory, my application crashes and i get the following message "User breakpoint called from code at 0x******". I think this means that some access violation occurs, but i don't understand why
I have some doubts in the code.....
i have put the name with comment.
This shuld be memory corruption problem, which u shuld debug to find out.
Raghuram
-
-
cryptReturnVal = new BYTE[len];
-
cryptReturnValueChar=new char[2*len+1];
-
-
// call decrypt function
-
cryptReturnVal=(*decrypt)(input, len, secretKey, ecretKeySize);
-
-
// convert result in hexadecimal format
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);
-
-
m_editOutput.SetWindowText(cryptReturnValueChar);
-
-
// free memory
-
delete [] cryptReturnVal;
-
delete [] cryptReturnValueChar;
-
In order to avoid the memory being overwritten on line 5, should I comment line 1? I tryied this but the same error occurs. Thanks
-
-
cryptReturnVal = new BYTE[len];
-
cryptReturnValueChar=new char[2*len+1];
-
-
// call decrypt function
-
cryptReturnVal=(*decrypt)(input, len, secretKey, ecretKeySize);
-
-
// convert result in hexadecimal format
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);//This is also overwriting the memory u have allocated.
-
-
m_editOutput.SetWindowText(cryptReturnValueChar);
-
-
// free memory
-
delete [] cryptReturnVal;
-
delete [] cryptReturnValueChar;
-
In order to avoid the memory being overwritten on line 5, should I comment line 1? I tryied this but the same error occurs. Thanks
Try to comment out the delete one by one and find which delete is causing the issue.Then u can dig there to find the issue.
Raghuram
This doesn't work:
cryptReturnVal = new BYTE[len];
char *cryptReturnValueChar;
// call decrypt function
cryptReturnVal=(*decrypt)(input, len, secretKey, ecretKeySize);
The return from decrypt is overwriting the address obtained by new just above. Now when you delete cryptReturnVal you will crash.
Try to comment out the delete one by one and find which delete is causing the issue.Then u can dig there to find the issue.
Raghuram
I already done that and i know that the problem is -
delete [] cryptReturnVal;
-
What i find odd, is the fact that the other value has no problem being deletede even though I declare it, I allocate memory for it in the same manner, it is the result of a function and then i try to delete it -
// declare variables
-
char *cryptReturnValueChar;
-
BYTE *cryptReturnVal;
-
-
// allocate memory
-
cryptReturnValueChar=new char[2*len+1];
-
cryptReturnVal=new BYTE[len];
-
-
// call crypt function
-
cryptReturnVal=(*crypt)(input, len, secretKey, secretKeySize);
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);
-
-
m_edit2.SetWindowText(cryptReturnValueChar);
-
// free memory
-
delete [] cryptReturnValueChar;
-
delete [] cryptReturnVal; // here is the problem
-
I understand what you all are saying that the memory is overwritten on line 10, when the crypt function is called, but what do you sugest me to do? I tryed commenting the line in which memory is allocated with new, but this still doesn't solve my problem; i get the same " User breakpoint called from code at 0x****** " error :(
I already done that and i know that the problem is -
delete [] cryptReturnVal;
-
What i find odd, is the fact that the other value has no problem being deletede even though I declare it, I allocate memory for it in the same manner, it is the result of a function and then i try to delete it -
// declare variables
-
char *cryptReturnValueChar;
-
BYTE *cryptReturnVal;
-
-
// allocate memory
-
cryptReturnValueChar=new char[2*len+1];
-
cryptReturnVal=new BYTE[len];
-
-
// call crypt function
-
cryptReturnVal=(*crypt)(input, len, secretKey, secretKeySize);
-
cryptReturnValueChar = fromCharToHexa(cryptReturnVal, len);
-
-
m_edit2.SetWindowText(cryptReturnValueChar);
-
// free memory
-
delete [] cryptReturnValueChar;
-
delete [] cryptReturnVal; // here is the problem
-
I understand what you all are saying that the memory is overwritten on line 10, when the crypt function is called, but what do you sugest me to do? I tryed commenting the line in which memory is allocated with new, but this still doesn't solve my problem; i get the same "User breakpoint called from code at 0x****** when using delete operator" error :(
Hi,
1)first check what the function pointer call return.
2)Then u can deceide whether u can delete the memory or not.
Raghuram
Hi,
1)first check what the function pointer call return.
2)Then u can deceide whether u can delete the memory or not.
Raghuram
-
typedef BYTE* (*DLLCRYPT) (BYTE*, UINT, BYTE*, UINT);
-
DLLCRYPT crypt;
-
..............................
-
crypt = (DLLCRYPT) GetProcAddress(hinstDLL, "crypt");
-
.................................................................................
-
cryptReturnVal=(*crypt)(input, len, secretKey, secretKeySize);
-
-
typedef BYTE* (*DLLCRYPT) (BYTE*, UINT, BYTE*, UINT);
-
DLLCRYPT crypt;
-
..............................
-
crypt = (DLLCRYPT) GetProcAddress(hinstDLL, "crypt");
-
.................................................................................
-
cryptReturnVal=(*crypt)(input, len, secretKey, secretKeySize);
-
Hi,
As it is returning a process address, i am very sure that u cant delete the memory.
If u have a memory-corruption identification tool u can use it.
Try Rational-Purify
Raghuram
LRESULT CWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// OnWndMsg does most of the work, except for DefWindowProc call
LRESULT lResult = 0;
if (!OnWndMsg(message, wParam, lParam, &lResult))
lResult = DefWindowProc(message, wParam, lParam);
return lResult;
}
I get a 'User breakpoint called from code at *******' error.
The lResult and the lparam values are both at zero. I am clueless as to how to proceed and will be grateful of any help I can receive.
This is not the only place where I get a 'user breakpoint' in debug mode. I get the same here too:
#ifndef _AFX_NO_DEBUG_CRT
// we remove WM_QUIT because if it is in the queue then the message box
// won't display
MSG msg;
BOOL bQuit = PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
BOOL bResult = _CrtDbgReport(_CRT_ASSERT, lpszFileName, nLine, NULL, NULL);
if (bQuit)
PostQuitMessage(msg.wParam);
return bResult;
The bQuit value stands at 0 here.
Help.
It would be better if you create a new thread.
If u are using windows then try heapchk() which will give the heap status.
Introduce this befor and after every function call and find oout where the memory is getting corrupted.
Raghu
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tobias Langner |
last post by:
I overloaded the operator= - but in the program, if the line p3=p1 gets
executed, the program doesn't jump to the method.
The class definition and the test code.
template <class T, template...
|
by: Tron Thomas |
last post by:
Given the following code:
#include <vector>
#include <algorithm>
#include <functional>
class Value
{
public:
explicit Value(int value) : m_value(value) {}
|
by: Aaron Queenan |
last post by:
When I build a C++ library to .NET using the managed C++ compiler, I get the
following error message:
Linking...
LINK : error LNK2020: unresolved token (0A000005) _CrtDbgReport
LINK : error...
|
by: Michael Ramey |
last post by:
Howdy, I think I have a good question!
I'm creating a usercontrol, and within this usercontrol, I'm dynamically
creating controls (imagebuttons to be exact), that the user can click on
which...
|
by: Kris van der Mast |
last post by:
Hi,
been a while since I posted a question myself instead of trying to help
others out.
I'm refactoring an existing web app that uses dynamic loading of user
controls and a lot of...
|
by: Razak |
last post by:
Hi,
I have a class which basically do Impersonation in my web application. From
MS KB sample:-
++++++++++++++++++++code starts
Dim impersonationContext As...
|
by: David |
last post by:
Hi all,
I posted my question two days ago, and tried to solve this problem.
but until now I didn't solve that. and I cut my codes so maybe this
time it is more readable.
...
|
by: jeffjohnson_alpha |
last post by:
We all know that a new-expression,
foo* a = new foo() ;
allocates memory for a single foo then calls foo::foo(). And we know
that
void* p = ::operator new(sizeof(foo)) ;
allocates a...
|
by: mail.dsp |
last post by:
Suppose in a class we overload four operators:
operator new
operator delete
operator new
operator delete
class Test{
public:
void * operator new (size_t t){
cout<<"\nCalling... new";
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |