Honestly, this is may be a dupe of VS2015: Migrated project compiles, but won't run ("Debug Assertion Failed!") but that has no answer and I have more details.
Is it possible that you are mixing up debug and release code? ucrtbased.dll is the debug universal CRT DLL. Windows maintains different heaps for debug versus release and mixing them can definitely cause errors like these. The different C runtime DLL's (e.g., VS2010, 2012, 2015) also maintain different heaps. Allocating memory on one heap and deallocating on another will cause these types of errors too.
See http://www.qtcentre.org/threads/29475-HEAP-VariousTests-exe-Invalid-Address-specified-to-RtlValidateHeap for example.