I'm having an issue with rendering text using DWrite.h in DirectX 11. I'm trying to wrote an application that will work as menu for my future game. When I'm displaying buttons, sometimes (not always) I'm getting error (visual studio shows it on ID2D1RenderTarget::EndDraw() in Button.cpp). Error ain't saying much ("Gra.exe has triggered a breakpoint") in lane which I've mentioned. When I click "Continue button" it displays that problem is about "corruption of heap". I've tried to find problem for my own for few days. I've checked all memory allocation etc., but I've found nothing. Weird thing is that this error is totally random - sometimes it shows, sometimes doesn't.
There are links to my codes:
I would be greatful for any help.