Bug 529695 --launcher.openFile with relative path crashes

Crash is caused due to a null pointer.

program (path) is a global var. It's being read by strlen before it's
set.

eclispe.c:417:run()
   -> parseArgs()
      -> next = checkPath(next, getProgramDir(), 0);
         checkPath() :
          paths[1] = .. programDir;
          buffer = malloc(.. _tcslen(paths[1])...)  << strlen on a null.

But it's only set later:
eclispe.c:417:run()
  -> parseArgs()  << used here.
  -> _run() {
     ->  program = _tcsdup( argv[0] );  << set here.
   }

Solution is fairly trivial, just set "program" before it's used.

Verified on  Linux Fedora 27. I don't see it causing issues on other
platforms, it's a very minor fix. Should probably be good to merge.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=529695
Change-Id: I379970ecce553ef4f78a246a96ee9ac647471739
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
1 file changed