[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Question about memory under MagiC



On Sat, 2011-10-22 at 23:56 +0200, Henk Robbers wrote:
> Op 10/22/11 11:45 PM, Jean-François Lemaire schreef:
> 
> > char path[PATHSIZE] = {0};
> > size_t size = snprintf(path, sizeof path, "%s%s", string1, string2) + 1;
> 
> If string1 + string2 exceeds sizeof path, the terminating \0 might not
> have been appended (happens also with strncpy).

No, snprintf always puts the terminating \0 inside the specified size of
the array. The problem here is incorrect evaluation of the return
value. 

Jo Even