opencv_trail_effect.cpp: fix potential leak when exiting during option parsing
authorAntonio Ospite <ao2@ao2.it>
Sat, 10 Oct 2020 17:38:10 +0000 (19:38 +0200)
committerAntonio Ospite <ao2@ao2.it>
Sat, 10 Oct 2020 17:38:10 +0000 (19:38 +0200)
When bailing out during option parsingi, for example when '-h' or an
invalid option is passed, some pointer to strings were not cleaned up,
leading to a potential leak, as reported by scan-build:

-----------------------------------------------------------------------
opencv_trail_effect.cpp:120:4: warning: Potential leak of memory pointed to by 'drawing_method'
                        usage(argv[0]);
                        ^~~~~
opencv_trail_effect.cpp:120:4: warning: Potential leak of memory pointed to by 'input_file'
                        usage(argv[0]);
                        ^~~~~
opencv_trail_effect.cpp:120:4: warning: Potential leak of memory pointed to by 'output_file'
                        usage(argv[0]);
                        ^~~~~
opencv_trail_effect.cpp:120:4: warning: Potential leak of memory pointed to by 'segmentation_method'
                        usage(argv[0]);
                        ^~~~~
opencv_trail_effect.cpp:123:4: warning: Potential leak of memory pointed to by 'drawing_method'
                        usage(argv[0]);
                        ^~~~~
opencv_trail_effect.cpp:123:4: warning: Potential leak of memory pointed to by 'segmentation_method'
                        usage(argv[0]);
                        ^~~~~
-----------------------------------------------------------------------

Stop using pointers to strings which really give no benefits in this
case and avoid the issue altogether.


No differences found