Visual C++ Developer Center > Visual C++ Forums > Visual C++ General > ASSERTE(_CrtIsValidHeapPointer(pUserData) error / RPC call
Ask a questionAsk a question
 

AnswerASSERTE(_CrtIsValidHeapPointer(pUserData) error / RPC call

  • Saturday, November 07, 2009 5:46 PMsambanman Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello, I need some Help and Direction.

    I am getting CrtIsValidHeapPointer when I am returning from Server function . here's my idl definition

    I have an RPC implelemtation where client calls  mgg_invalid and it populates msg and returns back to client.

    void mgg_invl(

    [

    in] CONTEXT_HANDLE hContext,

    [

    out,size_is(,80)] char **msg);


    and my Client implemenation

    *msg = (char

     

    *) midl_user_allocate(80*sizeof(char))


    but this always give me a run time error , that  using variable before initialize
    so i added
    msg = (char **)  malloc(char);

    and that compiled and ran but now i am getting Heap  error

    thanks

Answers

  • Monday, November 09, 2009 10:17 AMWesley YaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    I'm not very clear about your question, the code is unclear enough, could you please describe it more clear?
    Normally, this means your access is out-of-bound, I suspect the calling should be:

    char *msg = (char*)malloc(80 * sizeof(char));
    mgg_invl(&msg);

    Sincerely,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

All Replies

  • Monday, November 09, 2009 10:17 AMWesley YaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello,

    I'm not very clear about your question, the code is unclear enough, could you please describe it more clear?
    Normally, this means your access is out-of-bound, I suspect the calling should be:

    char *msg = (char*)malloc(80 * sizeof(char));
    mgg_invl(&msg);

    Sincerely,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • Friday, November 13, 2009 3:44 AMWesley YaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,

    How are you? Is your problem resolved? May I know whether the above suggestions helped you?

    Thanks,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.