fix off by one errors in calls to ast_copy_string (bug #4600)