From 99393bdfab67c889a3ecb0836a91e4fc268b634c Mon Sep 17 00:00:00 2001
From: Dario Casalinuovo <b.vitruvio@gmail.com>
Date: Thu, 2 Apr 2015 00:55:49 +0200
Subject: [PATCH 2/2] MediaFilePlayer: don't allocate fName in the heap, use
BString instead.
---
src/servers/media_addon/MediaFilePlayer.cpp | 4 +---
src/servers/media_addon/MediaFilePlayer.h | 3 ++-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/servers/media_addon/MediaFilePlayer.cpp b/src/servers/media_addon/MediaFilePlayer.cpp
index 9ce7818..0b997e2 100644
a
|
b
|
PlayMediaFile(const char* media_type, const char* media_name)
|
61 | 61 | MediaFilePlayer::MediaFilePlayer(const char* media_type, |
62 | 62 | const char* media_name, entry_ref* ref) |
63 | 63 | : |
| 64 | fName(media_name), |
64 | 65 | fInitCheck(B_ERROR), |
65 | 66 | fRef(*ref), |
66 | 67 | fSoundPlayer(NULL), |
67 | 68 | fPlayTrack(NULL) |
68 | 69 | { |
69 | | fName = strdup(media_name); |
70 | | |
71 | 70 | fPlayFile = new BMediaFile(&fRef); |
72 | 71 | fInitCheck = fPlayFile->InitCheck(); |
73 | 72 | if (fInitCheck != B_OK) |
… |
… |
MediaFilePlayer::~MediaFilePlayer()
|
111 | 110 | { |
112 | 111 | delete fSoundPlayer; |
113 | 112 | delete fPlayFile; |
114 | | free(fName); |
115 | 113 | } |
116 | 114 | |
117 | 115 | |
diff --git a/src/servers/media_addon/MediaFilePlayer.h b/src/servers/media_addon/MediaFilePlayer.h
index 508be95..5ef0bb5 100644
a
|
b
|
|
11 | 11 | #include <MediaFile.h> |
12 | 12 | #include <MediaTrack.h> |
13 | 13 | #include <SoundPlayer.h> |
| 14 | #include <String.h> |
14 | 15 | |
15 | 16 | |
16 | 17 | void PlayMediaFile(const char* media_type, const char* media_name); |
… |
… |
public:
|
38 | 39 | const media_raw_audio_format& format); |
39 | 40 | |
40 | 41 | private: |
41 | | char* fName; |
| 42 | BString fName; |
42 | 43 | status_t fInitCheck; |
43 | 44 | entry_ref fRef; |
44 | 45 | BSoundPlayer* fSoundPlayer; |