fix memory realloc size error.
fix name length to copy.
reformat coding styles.
check return value.
Merge pull request #1608 from zhangzl2013/bug-cliprdr

fix cliprdr bug