Null-terminate a string in MASM / GetModuleFileName-Collection of common programming errors
You need to add a zero to your variable at the end
.data
szSrc db "Your string",0
if you need to do it at the runtime you need to get the Length of your variable (szSrc), then you could write somthing like this :
lea eax,szSrc
mov byte ptr [eax+szSrcLen],0
Note : it is important to provide a valid Length .. , if you don’t know the correct string Length then it will be impossible to make a null string .