I've noticed that all deviser generated writers have issues with dereferencing NULL documents when writing. (This also happens in libSBML). The fix needs to go to:
generator/code_files/templates/Writer.cpp
This also needs to check that the error log is not NULL.