[text-highlight] Fix a possible memory leak

The related part of the code could be reached also when the 'syntax' variable
had been previously set to a newly allocated string, thus (try to) free it first.