Let $Q^d = D(p)$ be the market demand function, depending on price $p$. Let $p^*$ be equilibrium price (that depends also on supply of course). Then Consumer Surplus is usually defined as
$$\text{CS}=\int_{p^*}^\infty\!D(p)\,dp$$
i.e. the "area under the demand curve", starting from equilibrium price. So it appears, that if $D(p) =\bar q>0$ (perfectly inelastic demand), then we would have
$$\text{CS}=\int_{p^*}^\infty\!\bar q\,dp =\bar q \cdot p\Big|^{\infty}_{p^*}\rightarrow \infty$$
Hmm, this is mathematically sound, but is it useful/meaningful from an economics perspective?
The critical point is the upper limit of the integral of course: by putting it equal to "infinity" we assume that for any price, however high, there will be some demand, however minuscule. In reality, after a price demand will drop to zero (simple linear downward sloping demand curves have this realistic property). Even for totally inelastic demand, after a price all consumers will be "budgeted out" of the market -that they "desperately need" to have the product does not mean that they will indeed get it if the price exceeds, say, their total wealth. In a graph, this means that the vertical line representing demand has an upper end, it does not extend to the sky. So if we realistically take into account this fact, and denote this supremum price by $P_s<\infty$, we can redefine Consumer Surplus as
$$\text{CS}=\int_{p^*}^{P_s}\!D(p)\,dp$$
and for totally inelastic demand we obtain
$$\text{CS}=\int_{p^*}^{P_s}\!\bar q\,dp =\bar q \cdot (P_s-p^*)$$
Graphically,