[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fwd: Possible bug in the memory chunk management.]
From: |
Andreas Jaeger |
Subject: |
Re: [Fwd: Possible bug in the memory chunk management.] |
Date: |
Mon, 18 Feb 2002 07:05:29 +0100 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) XEmacs/21.4 (Artificial Intelligence, i386-suse-linux) |
Wolfram Gloger <address@hidden> writes:
> Hello,
>
>> You are right, we did made a mistake but nevertheless you missed
>> the point, Hence even if we will make buf_h = calloc(1, 7);
>> the problem is with the second loop who overwrite the buffer.
>
> No way, note that buf_h is a pointer to _pointers_ (or array of
> _pointers_), hence you need to make at least
>
> char **buf_h;
> buf_h = calloc(7, sizeof(char*));
>
> or
>
> buf_h = calloc(1, 7*sizeof(char*))
>
> if you want to later access buf_h[6].
>
>> Please take a second look at the source (change buf_h = calloc(1, 6) to
>> buf_h = calloc(1, 7); ) and still the output will be buf_h[4] = 1
>> This been tested on slackware linux 8.0.
>
> I haven't checked your source further.
The same is needed for buf_e but the rest looked fine.
Andreas
--
Andreas Jaeger
SuSE Labs address@hidden
private address@hidden
http://www.suse.de/~aj