mirror of https://github.com/mpv-player/mpv
stream: fix dvd:// + cache crashing
The language string was dynamically allocated, which completely fails if the cache is forked (which it usually is). Change it back to a fixed length string, like the original code had it.
This commit is contained in:
parent
efaa73cc73
commit
9085b85729
|
@ -910,7 +910,7 @@ static struct track *add_stream_track(struct MPContext *mpctx,
|
|||
track->demuxer_id)
|
||||
};
|
||||
stream_control(track->demuxer->stream, STREAM_CTRL_GET_LANG, &req);
|
||||
track->lang = talloc_steal(track, req.name);
|
||||
track->lang = talloc_strdup(track, req.name);
|
||||
}
|
||||
|
||||
return track;
|
||||
|
@ -941,7 +941,7 @@ static void add_dvd_tracks(struct MPContext *mpctx)
|
|||
|
||||
struct stream_lang_req req = {.type = STREAM_SUB, .id = n};
|
||||
stream_control(stream, STREAM_CTRL_GET_LANG, &req);
|
||||
track->lang = talloc_steal(track, req.name);
|
||||
track->lang = talloc_strdup(track, req.name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
struct stream_lang_req {
|
||||
int type; // STREAM_AUDIO, STREAM_SUB
|
||||
int id;
|
||||
char *name;
|
||||
char name[50];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
*/
|
||||
|
||||
#include <libbluray/bluray.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavutil/common.h"
|
||||
|
@ -215,7 +217,7 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
|
|||
}
|
||||
while (count-- > 0) {
|
||||
if (si->pid == req->id) {
|
||||
req->name = talloc_strndup(NULL, si->lang, 4);
|
||||
snprintf(req->name, sizeof(req->name), "%.4s", si->lang);
|
||||
bd_free_title_info(ti);
|
||||
return STREAM_OK;
|
||||
}
|
||||
|
|
|
@ -707,7 +707,7 @@ static int control(stream_t *stream,int cmd,void* arg)
|
|||
}
|
||||
if (!lang)
|
||||
break;
|
||||
req->name = talloc_strdup(NULL, (char[]) {lang >> 8, lang, 0});
|
||||
snprintf(req->name, sizeof(req->name), "%c%c", lang >> 8, lang);
|
||||
return STREAM_OK;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue