mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: fix memory management of the plot data
There was a global variable last_pi_entry_new, which stored the recently allocated plot data. This was freed when new plot data was generated. A very scary proposition: You can never have two plot datas at the same time! But exactly that happens when you export for example subtitles. The only reason why this didn't lead to very crazy behavior is that at least on my Linux machine, the calloc() call would just return the previously freed memory. Fix this mess by removing the global variable and freeing the data in the callers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5e9ffe3005
commit
69be1e23f2
4 changed files with 16 additions and 11 deletions
|
|
@ -191,6 +191,7 @@ static void put_st_event(struct membuffer *b, struct plot_data *entry, int offse
|
|||
}
|
||||
put_format(b, "\n");
|
||||
}
|
||||
|
||||
static void save_profiles_buffer(struct membuffer *b, bool select_only)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -211,6 +212,7 @@ static void save_profiles_buffer(struct membuffer *b, bool select_only)
|
|||
put_format(b, "\n");
|
||||
}
|
||||
put_format(b, "\n");
|
||||
free_plot_info_data(&pi);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +235,8 @@ void save_subtitles_buffer(struct membuffer *b, struct dive *dive, int offset, i
|
|||
put_st_event(b, &pi.entry[i], offset, length);
|
||||
}
|
||||
put_format(b, "\n");
|
||||
|
||||
free_plot_info_data(&pi);
|
||||
}
|
||||
|
||||
int save_profiledata(const char *filename, const bool select_only)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue