]> git.itanic.dy.fi Git - rrdd/commitdiff
onewire_parser: Fix memory leak when retrying OWNET_read()
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 24 Jul 2016 12:39:45 +0000 (15:39 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Sun, 24 Jul 2016 12:39:45 +0000 (15:39 +0300)
If it happens that read fails for any reason and the code retries
reading, the previous read buffer is not freed properly. This causes a
minor (26 byte) memory leak on each retry. Add a free() call to avoid
the leak.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
onewire_parser.c

index eb2ccd212b490ecead3ac58587087d1cac41d1e1..96bd5b2b0cfb8a873991f310f8ab6571683d2f55 100644 (file)
@@ -148,6 +148,7 @@ undefined:
                                goto undefined;
                        }
                        retries++;
+                       free(tmp);
                }
 
                /* The data from OWNET_read appears to not be NULL terminated */