diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-13 11:08:14 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-02-13 11:08:14 +0000 |
| commit | 19401e95e0a75577103e9c1a877611234a0d8ab5 (patch) | |
| tree | 08e5fd3519b2bd4e147e43c9ca7846e9ce7fd373 /untangle.c | |
| parent | 0a7c531e8f4c1970662f7c30aea006e65d5ff010 (diff) | |
| download | puzzles-19401e95e0a75577103e9c1a877611234a0d8ab5.zip puzzles-19401e95e0a75577103e9c1a877611234a0d8ab5.tar.gz puzzles-19401e95e0a75577103e9c1a877611234a0d8ab5.tar.bz2 puzzles-19401e95e0a75577103e9c1a877611234a0d8ab5.tar.xz | |
Don't leak duplicate edges in Untangle
Untangle game descriptions are allowed to contain duplicate edges, and
add234() can handle deduping them. However, when add234() reports that
your newly-allocated edge is a duplicate, it's important to free it
again.
Diffstat (limited to 'untangle.c')
| -rw-r--r-- | untangle.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -420,7 +420,9 @@ static void addedge(tree234 *edges, int a, int b) e->a = min(a, b); e->b = max(a, b); - add234(edges, e); + if (add234(edges, e) != e) + /* Duplicate edge. */ + sfree(e); } static bool isedge(tree234 *edges, int a, int b) |