Using the same variable as both input and output for spprintf looks dangerous. Are you sure it is safe?