Memory leaks are normally caused by poorly structured code. For example, if you malloc() your variables at the top of a function, then free them at the bottom, that's good; however, if you return in the middle of a function, that's bad. Returning should only be done at the end, anything else is considered sloppy. And if you return anywhere else, you could end up with a memory leak (for the reason I said above). So yeah, sloppy code CAN cause memory leaks.