Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6897059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:07:19+00:00 2026-05-27T07:07:19+00:00

Ok, this is perplexing me… The code below is in a DLL, and when

  • 0

Ok, this is perplexing me… The code below is in a DLL, and when my console application calls this code it is suddenly throwing an access violation at the line delete[] lpBuffer. I have been using this code all day and have not changed it at all. Until now, it had been working just fine.

Access Violation Message

Unhandled exception at 0x6948b1a5 in rhcopy.exe: 0xC0000005: Access violation reading location 0x4de1c37f.

Library Code

#define MAX_PACKET_SIZE  0x3FFF

DWORD MyClass::GetFile( LPCSTR lpszRemoteFile, LPCSTR lpszLocalFile )
{
    LPBYTE lpBuffer = NULL;

    // ...

    lpBuffer = new BYTE[MAX_PACKET_SIZE];

    // ...

    if( NULL != lpBuffer )
        delete[] lpBuffer;

    // ...
}

Am I doing something wrong?

On a side note: I have been thinking about converting lpBuffer into a vector. Opinions?

edit

I want to thank you guys for your help! But apparently… That’s not where the problem is. problem is actually a printf() statement in the calling application that occurs right after the call to GetFile(...). I apologize for the confusion. It would seem that Microsoft’s Debugging tool is not pointing to the line that caused the error, but rather the last line that executed. I have voted to close the question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:07:20+00:00Added an answer on May 27, 2026 at 7:07 am

    There is nothing wrong in the code you’ve shown here.

    Two possibilities come to mind:

    1. The error is not actually in the delete but in the code just on either side.

    2. You’ve done something to corrupt the heap, by using an invalid pointer that overwrites some random memory or deleting a pointer more than once.

    Neither of these problems would be caught by switching to RAII (i.e. vector) in the displayed code, but might improve things if you used them consistently in the rest of your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies for the rather verbose and long-winded post, but this problem's been perplexing me
I'm posing this question mostly out of curiosity. I've written some code that is
I have a simple, but perplexing problem, with Math. The following code will take
I'm finding the following a little perplexing... if I perform the below queries, when
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
I seem to have this perplexing issue with Moles not generating delegates, for some
this is my code to turn a byte[] array into an image unsafe {
This has been perplexing me for a couple of days, so I decided to
This problem has been perplexing me for a while now, and I've tried researching
This is perplexing to me. I want to change the frame of a UIScrollView

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.