Fix NULL filename handling
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 7 Nov 2022 16:26:44 +0000 (17:26 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 7 Nov 2022 16:36:06 +0000 (17:36 +0100)
The previous commit introduced a regression as some Ada tests end up passing
NULL as the filename to remap_filename.  Handle this as before to fix them.

gcc/
* file-prefix-map.cc (remap_filename): Handle NULL filenames.

gcc/file-prefix-map.cc

index 439586b..40b10ed 100644 (file)
@@ -73,7 +73,7 @@ remap_filename (file_prefix_map *maps, const char *filename)
   char *realname;
   size_t name_len;
 
-  if (lbasename (filename) == filename)
+  if (!filename || lbasename (filename) == filename)
     return filename;
 
   realname = lrealpath (filename);