This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On Wed, Dec 13, 2000 at 02:59:19PM +0100, Jakub Jelinek wrote:
> Hi!
>
> Since November, 27th changes gencat passes random pointers to obstack_free,
> which really does not make obstacks very happy (causes e.g. SIGBUS signals on
> sparc64). This also avoids passing a pointer given by obstack_alloc as line
> number.
>
Oops, my patch was buggy as well. This one should be better (passes make
check on sparc64).
From looking at obstack_ macros, I hope I can count on
y = obstack_alloc (x, n);
...
obstack_free (x, y);
z = obstack_alloc (x, m);
that if m <= n, then z == y.
2000-12-13 Jakub Jelinek <jakub@redhat.com>
* catgets/gencat.c (read_input_file): Avoid calling obstack_free
with a pointer not returned by obstack_ functions.
--- libc/catgets/gencat.c.jj Wed Dec 13 10:55:16 2000
+++ libc/catgets/gencat.c Wed Dec 13 15:44:29 2000
@@ -566,13 +566,14 @@ this is the first definition"));
else if (isalnum (this_line[0]) || this_line[0] == '_')
{
const char *ident = this_line;
+ char *line = this_line;
int message_number;
do
- ++this_line;
- while (this_line[0] != '\0' && !isspace (this_line[0]));
- if (this_line[0] != '\0')
- *this_line++ = '\0'; /* Terminate the identifier. */
+ ++line;
+ while (line[0] != '\0' && !isspace (line[0]));
+ if (line[0] != '\0')
+ *line++ = '\0'; /* Terminate the identifier. */
/* Now we found the beginning of the message itself. */
@@ -647,7 +648,7 @@ duplicated message identifier"));
char *outbuf;
size_t outlen;
struct message_list *newp;
- size_t this_line_len = strlen (this_line) + 1;
+ size_t line_len = strlen (line) + 1;
/* We need the conversion. */
if (cd_towc == (iconv_t) -1
@@ -662,8 +663,8 @@ duplicated message identifier"));
message is stateful. */
while (1)
{
- inbuf = this_line;
- inlen = this_line_len;
+ inbuf = line;
+ inlen = line_len;
outbuf = (char *) wbuf;
outlen = wbufsize;
@@ -693,8 +694,6 @@ invalid character: message ignored"));
wbuf = (wchar_t *) xrealloc (wbuf, wbufsize);
}
- used = 1; /* Yes, we use the line. */
-
/* Strip quote characters, change escape sequences into
correct characters etc. */
normalize_line (fname, start_line, cd_towc, wbuf,
@@ -711,8 +710,8 @@ invalid character: message ignored"));
inlen = (wcslen (wbuf) + 1) * sizeof (wchar_t);
outlen = obstack_room (¤t->mem_pool);
- start_line = (char *) obstack_alloc (¤t->mem_pool, outlen);
- outbuf = start_line;
+ this_line = (char *) obstack_alloc (¤t->mem_pool, outlen);
+ outbuf = this_line;
/* Flush the state. */
iconv (cd_tomb, NULL, NULL, NULL, NULL);
@@ -727,11 +726,15 @@ invalid character: message ignored"));
assert (outbuf[-1] == '\0');
/* Free the memory in the obstack we don't use. */
- obstack_free (¤t->mem_pool, outbuf);
+ obstack_free (¤t->mem_pool, this_line);
+ line = obstack_alloc (¤t->mem_pool, outbuf - this_line);
+ assert (line == this_line);
+
+ used = 1; /* Yes, we use the line. */
newp = (struct message_list *) xmalloc (sizeof (*newp));
newp->number = message_number;
- newp->message = this_line;
+ newp->message = line;
/* Remember symbolic name; is NULL if no is given. */
newp->symbol = ident;
/* Remember where we found the character. */
Jakub
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |