We assign the material name before check the pointer. Please Benoit check this and also I have a compiler warning about the second argument in the previous call of ConvertMaterialIpos, the argument is NULL but the function need a dword.