Is a linear functional on a locally convex space $X$ that continuous on a dense subset of X continuous?

Let $X$ be a locally convex space and let $M$ be a dense subset of $X$. Let $f$ be a linear functional on $X$ such that $f$ is continuous on $M$. Then is $f$ continuous on $X$?

Thank you in advance!

No, certainly not. For instance, $M\subset X$ could be a dense linear subspace and $f$ could come from a nonzero linear functional on the quotient space $X/M$, so $f$ vanishes on all of $M$ but not on $X$.
Let $X=C[0,1]$ with the sup norm and $M$ be the space of all polynomials on $[0,1]$. Let $A=\{1,x,x^{2},...\}$ and $B=\{e^{-x},e^{-2x},e^{-3x},...\}$ [ Of course, $x^{n}$ stands for the function $x \to x^{n}$ etc]. Then $A\cup B$ is linearly independent. By extending this to a basis we can construct a linear functional $f$ which is $0$ on $A$ such that $f(e^{-nx})=n$ for all $n$. Note that $\|e^{-nx}\|=1$ for all $n$. Hence this linear functional is not continuous but it is $0$ on the dense subspace $M$.
It is well-known that a linear functional $f$ on a topological vector space is discontinuous iff it kernel $\ker(f) = f^{-1}[\{0\}]$ is dense and continuous iff its kernel is closed. So in fact any discontinuous linear functional is continuous on a dense linear subspace (namely its kernel, on which it is constant).