1 |
solar 08/02/02 08:53:54 |
2 |
|
3 |
Modified: atom_explode.c |
4 |
Log: |
5 |
- fix the segfault when sidx == 0 |
6 |
|
7 |
Revision Changes Path |
8 |
1.25 portage-utils/libq/atom_explode.c |
9 |
|
10 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/libq/atom_explode.c?rev=1.25&view=markup |
11 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/libq/atom_explode.c?rev=1.25&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/portage-utils/libq/atom_explode.c?r1=1.24&r2=1.25 |
13 |
|
14 |
Index: atom_explode.c |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/atom_explode.c,v |
17 |
retrieving revision 1.24 |
18 |
retrieving revision 1.25 |
19 |
diff -u -r1.24 -r1.25 |
20 |
--- atom_explode.c 17 Jan 2008 06:35:08 -0000 1.24 |
21 |
+++ atom_explode.c 2 Feb 2008 08:53:53 -0000 1.25 |
22 |
@@ -1,7 +1,7 @@ |
23 |
/* |
24 |
* Copyright 2005-2008 Gentoo Foundation |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/atom_explode.c,v 1.24 2008/01/17 06:35:08 vapier Exp $ |
27 |
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/atom_explode.c,v 1.25 2008/02/02 08:53:53 solar Exp $ |
28 |
* |
29 |
* Copyright 2005-2008 Ned Ludd - <solar@g.o> |
30 |
* Copyright 2005-2008 Mike Frysinger - <vapier@g.o> |
31 |
@@ -36,8 +36,7 @@ |
32 |
{ |
33 |
depend_atom *ret; |
34 |
char *ptr; |
35 |
- size_t len, slen; |
36 |
- int i; |
37 |
+ size_t len, slen, idx, sidx; |
38 |
|
39 |
/* we allocate mem for atom struct and two strings (strlen(atom)). |
40 |
* the first string is for CAT/PN/PV while the second is for PVR. |
41 |
@@ -101,24 +100,24 @@ |
42 |
strcpy(ret->P, ret->PN); |
43 |
|
44 |
/* break out all the suffixes */ |
45 |
- size_t sidx = 0; |
46 |
+ sidx = 0; |
47 |
ret->suffixes = xrealloc(ret->suffixes, sizeof(atom_suffix) * (sidx + 1)); |
48 |
ret->suffixes[sidx].sint = 0; |
49 |
ret->suffixes[sidx].suffix = VER_NORM; |
50 |
while ((ptr = strrchr(ret->PN, '_')) != NULL) { |
51 |
- for (i = 0; i < ARRAY_SIZE(atom_suffixes_str); ++i) { |
52 |
- if (strncmp(ptr, atom_suffixes_str[i], strlen(atom_suffixes_str[i]))) |
53 |
+ for (idx = 0; idx < ARRAY_SIZE(atom_suffixes_str); ++idx) { |
54 |
+ if (strncmp(ptr, atom_suffixes_str[idx], strlen(atom_suffixes_str[idx]))) |
55 |
continue; |
56 |
|
57 |
/* check this is a real suffix and not _p hitting mod_perl */ |
58 |
char *tmp_ptr = ptr; |
59 |
- tmp_ptr += strlen(atom_suffixes_str[i]); |
60 |
+ tmp_ptr += strlen(atom_suffixes_str[idx]); |
61 |
ret->suffixes[sidx].sint = atoll(tmp_ptr); |
62 |
while (isdigit(*tmp_ptr)) |
63 |
++tmp_ptr; |
64 |
if (*tmp_ptr) |
65 |
goto no_more_suffixes; |
66 |
- ret->suffixes[sidx].suffix = i; |
67 |
+ ret->suffixes[sidx].suffix = idx; |
68 |
|
69 |
++sidx; |
70 |
*ptr = '\0'; |
71 |
@@ -132,11 +131,12 @@ |
72 |
break; |
73 |
} |
74 |
no_more_suffixes: |
75 |
- --sidx; |
76 |
- for (i = 0; i < sidx; ++i, --sidx) { |
77 |
+ if (sidx) |
78 |
+ --sidx; |
79 |
+ for (idx = 0; idx < sidx; ++idx, --sidx) { |
80 |
atom_suffix t = ret->suffixes[sidx]; |
81 |
- ret->suffixes[sidx] = ret->suffixes[i]; |
82 |
- ret->suffixes[i] = t; |
83 |
+ ret->suffixes[sidx] = ret->suffixes[idx]; |
84 |
+ ret->suffixes[idx] = t; |
85 |
} |
86 |
|
87 |
/* allow for 1 optional suffix letter */ |
88 |
|
89 |
|
90 |
|
91 |
-- |
92 |
gentoo-commits@l.g.o mailing list |