ref: e336513be755159158c5ba017c91b018ad4cd36c
parent: 73c7bc090155ab8c4661feaeea9e6a6e74ee6f77
author: Ben Harris <bjh21@bjh21.me.uk>
date: Mon Feb 13 15:17:58 EST 2023
Loopy: free the grid description string if it's invalid
--- a/loopy.c
+++ b/loopy.c
@@ -777,10 +777,13 @@
* know is the precise number of faces. */
grid_desc = extract_grid_desc(&desc);
ret = grid_validate_desc(grid_types[params->type], params->w, params->h, grid_desc);
- if (ret) return ret;
+ if (ret) {
+ sfree(grid_desc);
+ return ret;
+ }
g = loopy_generate_grid(params, grid_desc);
- if (grid_desc) sfree(grid_desc);
+ sfree(grid_desc);
for (; *desc; ++desc) {
if ((*desc >= '0' && *desc <= '9') || (*desc >= 'A' && *desc <= 'Z')) {