Re: [PATCH v2 2/3] textconv: support for blame
From: Matthieu Moy <hidden>
Date: 2016-06-15 22:48:58
bonneta [off-list ref] writes:
But we have to do: textconv_object(read_from, null_sha1, &buf.buf, (unsigned long *) &buf.len)) where buf.len is size_t. Is that ok?
I don't think it fixes the problem. You're assuming sizeof(unsigned
long) == sizeof(size_t), otherwise, textconv_object will write the
incorrect number of bytes at the given adress.
If you have to use this pass-by-adress, you want
size_t buf_len; /* textconv_object needs a last parameter of type
(size_t *) */
textconv_object(..., &buf_len); /* <-- no cast here */
buf.len = buf_len; /* This is a cast, but not a pointer cast. The
compiler will do the actual conversion if
needed (while pointer casts are just a matter of
typing, the generate no code). */
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/