avoid free(NULL) in previous commit

some systems may not support it.