Message ID | eb6dddb0-438b-317b-50e2-cbd06a367ea1@netcologne.de |
---|---|
State | New |
Headers | show |
On Sun, Jul 23, 2017 at 10:23 PM, Thomas Koenig <tkoenig@netcologne.de> wrote: > Hello world, > > the attached test cases fixes a problematic invocation of > memcpy where src=NULL and n=0 by simply doing nothing > in the surrounding function if there is nothing to be done. > > No test case, because this only shows up with a sanitized > libgfortran or under a debugger. > > OK for trunk? Good catch, Ok.
Hi Janne, > On Sun, Jul 23, 2017 at 10:23 PM, Thomas Koenig <tkoenig@netcologne.de> wrote: >> Hello world, >> >> the attached test cases fixes a problematic invocation of >> memcpy where src=NULL and n=0 by simply doing nothing >> in the surrounding function if there is nothing to be done. >> >> No test case, because this only shows up with a sanitized >> libgfortran or under a debugger. >> >> OK for trunk? > > Good catch, Ok. Committed, thanks for the review. What is the opinion on backporting? We should avoid undefined behavior in the library, I think, so I am leanding towards doing it. Regards Thomas
On Mon, Jul 24, 2017 at 2:12 PM, Thomas Koenig <tkoenig@netcologne.de> wrote: > Hi Janne, > >> On Sun, Jul 23, 2017 at 10:23 PM, Thomas Koenig <tkoenig@netcologne.de> >> wrote: >>> >>> Hello world, >>> >>> the attached test cases fixes a problematic invocation of >>> memcpy where src=NULL and n=0 by simply doing nothing >>> in the surrounding function if there is nothing to be done. >>> >>> No test case, because this only shows up with a sanitized >>> libgfortran or under a debugger. >>> >>> OK for trunk? >> >> >> Good catch, Ok. > > > > Committed, thanks for the review. > > What is the opinion on backporting? We should avoid undefined > behavior in the library, I think, so I am leanding towards > doing it. > > Regards > > Thomas > Sure, go ahead. I can't see how the patch would cause any bugs (knock knock...), so it seems quite safe. BTW, there might be a similar issue in buf_read()?
Index: io/unix.c =================================================================== --- io/unix.c (Revision 249936) +++ io/unix.c (Arbeitskopie) @@ -582,6 +582,9 @@ static ssize_t buf_write (unix_stream *s, const void *buf, ssize_t nbyte) { + if (nbyte == 0) + return 0; + if (s->ndirty == 0) s->buffer_offset = s->logical_offset;