I'm not an winapi expert (and don't want to be, in fact :)), but it seems as a duplicate data copy without check for _wcsdup result (it can return NULL).