[vlc-commits] [Git][videolan/vlc][master] modules: decklink: fix possible pointer aliasing issues

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sat Mar 12 15:39:25 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
80cded3b by Steve Lhomme at 2022-03-12T15:27:08+00:00
modules: decklink: fix possible pointer aliasing issues

Decklink uses a COM like API on Linux and macOS but there's no WRL there or
__uuidof(). So we have to use the safe COM handling.

- - - - -


3 changed files:

- modules/access/decklink.cpp
- modules/stream_out/sdi/DBMSDIOutput.cpp
- modules/video_output/decklink.cpp


Changes:

=====================================
modules/access/decklink.cpp
=====================================
@@ -545,6 +545,7 @@ static int Open(vlc_object_t *p_this)
     int         physical_channels = 0;
     int         rate;
     BMDVideoInputFlags flags = bmdVideoInputFlagDefault;
+    void *pv;
 
     if (demux->out == NULL)
         return VLC_EGENERIC;
@@ -593,21 +594,24 @@ static int Open(vlc_object_t *p_this)
     msg_Dbg(demux, "Opened DeckLink PCI card %d (%s)", card_index, model_name);
     free(model_name);
 
-    if (sys->card->QueryInterface(IID_IDeckLinkInput, (void**)&sys->input) != S_OK) {
+    if (sys->card->QueryInterface(IID_IDeckLinkInput, &pv) != S_OK) {
         msg_Err(demux, "Card has no inputs");
         goto finish;
     }
+    sys->input = static_cast<IDeckLinkInput*>(pv);
 
     /* Set up the video and audio sources. */
-    if (sys->card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&sys->config) != S_OK) {
+    if (sys->card->QueryInterface(IID_IDeckLinkConfiguration, &pv) != S_OK) {
         msg_Err(demux, "Failed to get configuration interface");
         goto finish;
     }
+    sys->config = static_cast<IDeckLinkConfiguration*>(pv);
 
-    if (sys->card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&sys->attributes) != S_OK) {
+    if (sys->card->QueryInterface(IID_IDeckLinkProfileAttributes, &pv) != S_OK) {
         msg_Err(demux, "Failed to get attributes interface");
         goto finish;
     }
+    sys->attributes = static_cast<IDeckLinkProfileAttributes*>(pv);
 
     if (GetVideoConn(demux) || GetAudioConn(demux))
         goto finish;


=====================================
modules/stream_out/sdi/DBMSDIOutput.cpp
=====================================
@@ -213,8 +213,10 @@ int DBMSDIOutput::Open()
     msg_Dbg(p_stream, "Opened DeckLink PCI card %s", psz_model_name);
     free(psz_model_name);
 
-    result = p_card->QueryInterface(IID_IDeckLinkOutput, (void**)&p_output);
+    void *pv;
+    result = p_card->QueryInterface(IID_IDeckLinkOutput, &pv);
     CHECK("No outputs");
+    p_output = static_cast<IDeckLinkOutput*>(pv);
 
     decklink_iterator->Release();
 
@@ -258,8 +260,10 @@ int DBMSDIOutput::ConfigureAudio(const audio_format_t *)
     {
         uint8_t maxchannels = audioMultiplex->config.getMultiplexedFramesCount() * 2;
 
-        result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
+        void *pv;
+        result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, &pv);
         CHECK("Could not get IDeckLinkAttributes");
+        p_attributes = static_cast<IDeckLinkProfileAttributes*>(pv);
 
         int64_t i64;
         result = p_attributes->GetInt(BMDDeckLinkMaximumAudioChannels, &i64);
@@ -333,6 +337,7 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
     IDeckLinkDisplayMode *p_display_mode = NULL;
     char *psz_string = NULL;
     video_format_t *fmt = &video.configuredfmt.video;
+    void *pv;
 
     if(FAKE_DRIVER)
     {
@@ -354,8 +359,9 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
     if(!p_output)
         return VLC_EGENERIC;
 
-    result = p_card->QueryInterface(IID_IDeckLinkConfiguration, (void**)&p_config);
+    result = p_card->QueryInterface(IID_IDeckLinkConfiguration, &pv);
     CHECK("Could not get config interface");
+    p_config = static_cast<IDeckLinkConfiguration*>(pv);
 
     psz_string = var_InheritString(p_stream, CFG_PREFIX "mode");
     if(psz_string)
@@ -372,8 +378,9 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt)
     }
 
     /* Read attributes */
-    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
+    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, &pv);
     CHECK("Could not get IDeckLinkAttributes");
+    p_attributes = static_cast<IDeckLinkProfileAttributes*>(pv);
 
 #ifdef _WIN32
     LONGLONG iconn;


=====================================
modules/video_output/decklink.cpp
=====================================
@@ -418,6 +418,7 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys, video_format_t
     IDeckLinkConfiguration *p_config = NULL;
     IDeckLinkProfileAttributes *p_attributes = NULL;
     IDeckLink *p_card = NULL;
+    void *pv;
     union {
         BMDDisplayMode id;
         char str[4];
@@ -480,8 +481,9 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys, video_format_t
 
     /* Read attributes */
 
-    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, (void**)&p_attributes);
+    result = p_card->QueryInterface(IID_IDeckLinkProfileAttributes, &pv);
     CHECK("Could not get IDeckLinkAttributes");
+    p_attributes = static_cast<IDeckLinkProfileAttributes*>(pv);
 
 #ifdef _WIN32
     LONGLONG iconn;
@@ -492,13 +494,13 @@ static int OpenDecklink(vout_display_t *vd, decklink_sys_t *sys, video_format_t
     result = p_attributes->GetInt(BMDDeckLinkVideoOutputConnections, &iconn); /* reads mask */
     CHECK("Could not get BMDDeckLinkVideoOutputConnections");
 
-    result = p_card->QueryInterface(IID_IDeckLinkOutput,
-        (void**)&sys->p_output);
+    result = p_card->QueryInterface(IID_IDeckLinkOutput, &pv);
     CHECK("No outputs");
+    sys->p_output = static_cast<IDeckLinkOutput*>(pv);
 
-    result = p_card->QueryInterface(IID_IDeckLinkConfiguration,
-        (void**)&p_config);
+    result = p_card->QueryInterface(IID_IDeckLinkConfiguration, &pv);
     CHECK("Could not get config interface");
+    p_config = static_cast<IDeckLinkConfiguration*>(pv);
 
     /* Now configure card */
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/80cded3b6ac5ff9aabc9967726f3d7f2f901bd72

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/80cded3b6ac5ff9aabc9967726f3d7f2f901bd72
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list