]> sigrok.org Git - libserialport.git/commit
windows: Avoid leak of write buffer on realloc failure.
authorMartin Ling <redacted>
Fri, 24 Jan 2020 04:44:47 +0000 (04:44 +0000)
committerMartin Ling <redacted>
Fri, 24 Jan 2020 05:39:16 +0000 (05:39 +0000)
commit988ace6c9f8035e5835847d38a6dbf654ea216da
tree984ebf02f7fcc026066418340f0582070d89a01b
parentbf40b1cea9eb2e13d13f05118fe11b43be621485
windows: Avoid leak of write buffer on realloc failure.

VS2019 IntelliSense reported:

Warning C6308: 'realloc' might return null pointer: assigning null
               pointer to 'port->write_buf', which is passed as an
       argument to 'realloc', will cause the original memory
       block to be leaked.

This is correct, we would leak the buffer on a realloc failure.

Put the realloc result in a separate variable and handle the error
path before assigning the result to port->write_buf.
serialport.c