mirror of
https://github.com/mpv-player/mpv
synced 2025-02-26 10:14:33 +00:00
ao_pcm: fix double free on exit
This seems to be an older bug. It set priv->outputfilename to a new talloc-allocated string, but the field is also managed as string option, so talloc will free it first, then m_option_free() is called on the dangling pointer. Possibly this is caused by the earlier ta destruction order change.
This commit is contained in:
parent
cd22e93fee
commit
9d04e76f3f
@ -111,9 +111,11 @@ static int init(struct ao *ao)
|
|||||||
{
|
{
|
||||||
struct priv *priv = ao->priv;
|
struct priv *priv = ao->priv;
|
||||||
|
|
||||||
if (!priv->outputfilename)
|
char *outputfilename = priv->outputfilename;
|
||||||
priv->outputfilename =
|
if (!outputfilename) {
|
||||||
talloc_strdup(priv, priv->waveheader ? "audiodump.wav" : "audiodump.pcm");
|
outputfilename = talloc_strdup(priv, priv->waveheader ? "audiodump.wav"
|
||||||
|
: "audiodump.pcm");
|
||||||
|
}
|
||||||
|
|
||||||
ao->format = af_fmt_from_planar(ao->format);
|
ao->format = af_fmt_from_planar(ao->format);
|
||||||
|
|
||||||
@ -148,13 +150,13 @@ static int init(struct ao *ao)
|
|||||||
ao->bps = ao->channels.num * ao->samplerate * af_fmt_to_bytes(ao->format);
|
ao->bps = ao->channels.num * ao->samplerate * af_fmt_to_bytes(ao->format);
|
||||||
|
|
||||||
MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n",
|
MP_INFO(ao, "File: %s (%s)\nPCM: Samplerate: %d Hz Channels: %d Format: %s\n",
|
||||||
priv->outputfilename,
|
outputfilename,
|
||||||
priv->waveheader ? "WAVE" : "RAW PCM", ao->samplerate,
|
priv->waveheader ? "WAVE" : "RAW PCM", ao->samplerate,
|
||||||
ao->channels.num, af_fmt_to_str(ao->format));
|
ao->channels.num, af_fmt_to_str(ao->format));
|
||||||
|
|
||||||
priv->fp = fopen(priv->outputfilename, priv->append ? "ab" : "wb");
|
priv->fp = fopen(outputfilename, priv->append ? "ab" : "wb");
|
||||||
if (!priv->fp) {
|
if (!priv->fp) {
|
||||||
MP_ERR(ao, "Failed to open %s for writing!\n", priv->outputfilename);
|
MP_ERR(ao, "Failed to open %s for writing!\n", outputfilename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (priv->waveheader) // Reserve space for wave header
|
if (priv->waveheader) // Reserve space for wave header
|
||||||
|
Loading…
Reference in New Issue
Block a user