I think the problem occurs because you wrote on memory that you don't own sizeof
return how many bits does the datatype takes in memory and since your are given it an int
it probably return 4 or 8 according to your system
So I think a fix for your problem will be (Char*)malloc(sizeof(char) * Length + 1)