Indentation crash in 4.0.11 super

I have these keys bound to the builtin command write_and_auto_tab, all with MDFR_NONE:
1
'\t','}',')','\n',']','#',';'

Most of them work fine all of the time, except for the '#' key. If it is the first non-whitespace character in a file, 4coder will crash on attempting to type it. The VS debugger shows that find_anchor_token in 4coder_auto_indent.cpp is where the crash takes place because of an attempt to dereference a null pointer returned by get_first_token_at_line. Further investigation also reveals that certain other symbols such as '$' will crash at the same place when bound to write_and_auto_tab. Alphanumeric characters such as 'm' and '4' will also crash when bound, but in get_indent_lines_whole_tokens instead of in find_anchor_token. The crash is still due to the same problem of dereferencing a null pointer returned by get_first_token_at_line.

As you can imagine, this causes some headaches for me since most of my files start with an #include or #pragma. I've unbound the '#' key from auto-indenting for now. Can anyone else reproduce this problem?
Yeah this is a known issue in 4.0.11 that a few people have already reported. It is fixed in the incomplete alpha 4.0.12 build, but since this seems to be a very wide spread problem at this point I'll post a patch for alpha 4.0.11 that fixes the issue.


EDIT: The patch is uploaded for backers.

Edited by Allen Webster on