Package: glibc / 2.24-11+deb9u4

locale/fix-LC_COLLATE-rules.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
 locale/programs/ld-collate.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1554,6 +1554,7 @@
   int i;
   int need_undefined = 0;
   struct section_list *sect;
+  enum coll_sort_rule *orules;
   int ruleidx;
   int nr_wide_elems = 0;
 
@@ -1565,18 +1566,28 @@
 				"LC_COLLATE"));
       return;
     }
+  if (nrules == 0)
+    {
+      /* An error message has already been printed:
+          empty category description not allowed.  */
+      return;
+    }
 
   /* If this assertion is hit change the type in `element_t'.  */
   assert (nrules <= sizeof (runp->used_in_level) * 8);
 
   /* Make sure that the `position' rule is used either in all sections
      or in none.  */
+  sect = collate->sections;
+  while (sect != NULL && sect->rules == NULL)
+    sect = sect->next;
+  orules = sect->rules;
   for (i = 0; i < nrules; ++i)
     for (sect = collate->sections; sect != NULL; sect = sect->next)
       if (sect != collate->current_section
 	  && sect->rules != NULL
 	  && ((sect->rules[i] & sort_position)
-	      != (collate->current_section->rules[i] & sort_position)))
+	      != (orules[i] & sort_position)))
 	{
 	  WITH_CUR_LOCALE (error (0, 0, _("\
 %s: `position' must be used for a specific level in all sections or none"),
@@ -3359,6 +3370,9 @@
 		      no_error = 0;
 		    }
 		}
+	      /* Update current section.  */
+	      if (collate->cursor != NULL)
+	        collate->current_section = collate->cursor->section;
 
 	      lr_ignore_rest (ldfile, no_error);
 	    }