you must alloocate obj.length + 1. '+1' is for '\0' that compiler adds automatically