lto-streamer-out.c (cmp_symbol_files): Watch for overflow.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 23 Oct 2019 20:01:25 +0000 (22:01 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 23 Oct 2019 20:01:25 +0000 (20:01 +0000)
* lto-streamer-out.c (cmp_symbol_files): Watch for overflow.

From-SVN: r277348

gcc/ChangeLog
gcc/lto-streamer-out.c

index d6c0c9ec6ee06cc5ded62cfcaf121706ce483acd..b975798166cefd7c5008d6dafb10907d1964724a 100644 (file)
@@ -1,3 +1,7 @@
+2019-10-23  Jan Hubicka  <hubicka@ucw.cz>
+
+       * lto-streamer-out.c (cmp_symbol_files): Watch for overflow.
+
 2019-10-23  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-reference.c (varpool_removal_hook, ipa_reference_c_finalize): Fix
index 2c712926f32a5db8a67e16497a15dafc201dcbb8..3ecadddec52832603bb3cbf17df9984509433560 100644 (file)
@@ -2447,7 +2447,12 @@ cmp_symbol_files (const void *pn1, const void *pn2)
 
   /* Order within static library.  */
   if (n1->lto_file_data && n1->lto_file_data->id != n2->lto_file_data->id)
-    return n1->lto_file_data->id - n2->lto_file_data->id;
+    {
+      if (n1->lto_file_data->id > n2->lto_file_data->id)
+       return 1;
+      if (n1->lto_file_data->id < n2->lto_file_data->id)
+       return -1;
+    }
 
   /* And finaly order by the definition order.  */
   return n1->order - n2->order;