Resolve possible NULL pointer dereference 'buffer'

It is not guaranteed that buffer is not NULL at this statement.