set terminal svg
set output 'test.svg'
This script writes a corrupted svg file, which contains one extra tag without opening . Everything seems OK without "replot".
Gnuplot 4.6.4, Fedora 19, 64-bit Intel.
Sorry for not sanitizing the tags. It is </g> without matching <g>.
The breakage seems to have occurred between 4.4.4 and 4.6.0.
On the other hand, this sequence of commands makes little sense for svg output. Unlike page-oriented formats (PostScript, PDF) or interactive displays that allow sequential inspection of plots (x11, wxt, qt), svg documents are not intended to hold more than one full-page display element. Even if the number of \<g>/\</g> pairings were correct, the 2 plots would lie on top of each other. The normal sequence would be to either reopen the output svg file (new "set output" command) before the "replot", or wrap both the 1st and 2nd plots in a multiplot sequence:
set multiplot layout 2,1
So while I agree than producing a corrupt document is not helpful, fixing that will only reveal an underlying problem in the command sequence that produced it.
I just opened and closed (as duplicate) a bug for this same issue. Just posting the link here in case any information from the other bug is going to be useful for fixing the issue: https://sourceforge.net/p/gnuplot/bugs/1397/