The source location is around lsof-4.91+dfsg/dialects/linux/dproc.c,
lines 1568 to 1602.
Looking at 'ps aux', a different approach is used there:
The file /proc/[pid]/stat gets read as a whole and then
searched for the first '(' and then in reverse direction
from the end for the ')'.
In procps-3.3.15/proc/readproc.c, lines 597 and 600.
Maybe lsof could also use libprocps7 for that, too?
PS.: It looks like the value set by perl is even when terminated a
lot longer than '('. Therefore 'ps aux' prints a lot of spaces
for the process name. Would that justify to open an bug there too?