> I don't know why would I get this error when my code was running perfectly few days ago?
Do you use git / mercurial / anything ?
You should be making at least daily commits to your local repo. Or better yet, after every edit/test cycle which improved the program in some way.
With a repo, you could have done a diff between what "worked" and what is broken.
With a repo, you could have checked out an older 'working' version, run it under valgrind to see if it was as good as you imagine it to be.
If you're doing any programming which is more than the single file throw away homework, it's the next essential tool right up there with the debugger.
Memory problems are insidious. It's all too easy for the first mistake to go unnoticed. By the time you actually notice, it could be a long time and a lot of changes. Worse still, where the problem shows up is often not where the real root cause is.
Valgrind is good for finding leaks in otherwise well behaved programs.
If you're looking for memory overruns and use-after-free problems, I'd suggest
https://elinux.org/Electric_Fence
Run the program linked with electric fence in the debugger.
Oh, and never equate "working" as "bug-free".
You only have to see the regular stream of patches for pretty much everything you use to understand this.