Topic: [SOLVED] Memory free

I'm running the MQX port of version wolfSSL embedded SSL 2.8.0.  I've noticed when a session is closed an error in thrown by MQX for trying to free a NULL pointer.  It appers the wolfSSL library frees memory twice after the handshake (FreeHandshakeResources()) and after the session is closed (SSL_ResourceFree()).  MQX can be built to remove this check, which could result in some bad behavior.  I've addressed the problem by checking the pointer before XFREE is called.  Is this known behavior and is it expected that the free routine should catch NULL pointers?

Thanks

Share

Re: [SOLVED] Memory free

Hi jmazza,

Thanks for brining this to our attention.  I believe you are correct.  There should be a check to make sure the pointer is not NULL before we try to free it with the XFREE definition in the FREESCALE_MQX define of ./wolfssl/ctaocrypt/settings.h.

In ./wolfssl/ctaocrypt/settings.h, under the code block for FREESCALE_MQX, can you try changing the XFREE definition from:

#define XFREE(p, h, type)   _mem_free(p)

to

#define XFREE(p, h, type)  {void* xp = (p); if((xp)) _mem_free(xp);}

Thanks,
Chris

Re: [SOLVED] Memory free

Thanks for following up and this addresses the issue.

Joe

Share

Re: [SOLVED] Memory free

Hi Joe,

I just pushed that fix, which should roll out with our next stable release:
https://github.com/cyassl/cyassl/commit … a7995a54f1

Thanks,
Chris