Searched hist:a2229407e54a7e9afdb4310b426fa14676c893f7 (Results 1 – 1 of 1) sorted by relevance
/freebsd/usr.bin/fmt/ |
H A D | fmt.c | diff a2229407e54a7e9afdb4310b426fa14676c893f7 Wed Oct 17 13:41:40 CEST 2007 Juli Mallett <jmallett@FreeBSD.org> Prevent strange crashes in fmt with absurd goal lengths introduced by the support for wide characters.
If the sizeof (wchar_t) times max_length would yield a value beyond representation in a size_t, exit with a usage error up front, rather than strange errors down the line from trying to malloc (well, realloc) with a size of 0.
This is perhaps not the optimal behaviour - a clamp may be more appropriate as we clamp the value of max_length now anyway, but this is at least better than segfaulting or worse. On systems which are friendly to malloc with a value of 0 the results could end up being strange corruption of the output. diff a2229407e54a7e9afdb4310b426fa14676c893f7 Wed Oct 17 13:41:40 CEST 2007 Juli Mallett <jmallett@FreeBSD.org> Prevent strange crashes in fmt with absurd goal lengths introduced by the support for wide characters.
If the sizeof (wchar_t) times max_length would yield a value beyond representation in a size_t, exit with a usage error up front, rather than strange errors down the line from trying to malloc (well, realloc) with a size of 0.
This is perhaps not the optimal behaviour - a clamp may be more appropriate as we clamp the value of max_length now anyway, but this is at least better than segfaulting or worse. On systems which are friendly to malloc with a value of 0 the results could end up being strange corruption of the output.
|