File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -425,7 +425,16 @@ int main(int argc, char** argv) {
425425 (void )verbose_flag ;
426426
427427 char * src = NULL ;
428- const char * source_label = path ;
428+ char * source_label = NULL ;
429+ /* Canonicalize the provided program path now so it's correct even if
430+ the process changes cwd below. This prevents relative paths like
431+ "./tests/test2.pre" from resolving incorrectly after chdir. */
432+ #if defined(_MSC_VER )
433+ if (path ) source_label = _fullpath (NULL , path , 0 );
434+ #else
435+ if (path ) source_label = realpath (path , NULL );
436+ #endif
437+ if (!source_label && path ) source_label = strdup (path );
429438
430439 FILE * f = fopen (path , "rb" );
431440 if (!f ) {
@@ -498,6 +507,7 @@ int main(int argc, char** argv) {
498507 }
499508
500509 free (src );
510+ if (source_label ) free (source_label );
501511 extensions_shutdown ();
502512 builtins_reset_dynamic ();
503513 return PREFIX_SUCCESS ;
You can’t perform that action at this time.
0 commit comments