Skip to content

Commit

Permalink
worksheet: fix resource leaks on error paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcnamara committed Oct 25, 2024
1 parent 7ba204a commit 67c9faa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/worksheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -9626,12 +9626,16 @@ worksheet_set_selection(lxw_worksheet *self,

/* Check that row and col are valid without storing. */
err = _check_dimensions(self, first_row, first_col, LXW_TRUE, LXW_TRUE);
if (err)
if (err) {
free(selection);
return err;
}

err = _check_dimensions(self, last_row, last_col, LXW_TRUE, LXW_TRUE);
if (err)
if (err) {
free(selection);
return err;
}

/* Set the cell range selection. Do this before swapping max/min to */
/* allow the selection direction to be reversed. */
Expand Down Expand Up @@ -10677,8 +10681,10 @@ worksheet_embed_image_opt(lxw_worksheet *self,

/* Check and store the cell dimensions. */
err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
if (err)
if (err) {
fclose(image_stream);
return err;
}

/* Create a new object to hold the image properties. */
object_props = calloc(1, sizeof(lxw_object_properties));
Expand Down

0 comments on commit 67c9faa

Please sign in to comment.