The buffers and buffer sizes should be initialized and allocated. This patch fixies a possible case where vdagent can get stuck, as the function _pfnQueryDisplayConfig can return ERROR_INVALID_PARAMETER if the buffers aren't intialized. The call to free_config_buffers is superfluous becuase it is called inside get_config_buffers. Signed-off-by: Sameeh Jubran <sameeh@xxxxxxxxxx> --- vdagent/display_configuration.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/vdagent/display_configuration.cpp b/vdagent/display_configuration.cpp index bab4c95..409725e 100644 --- a/vdagent/display_configuration.cpp +++ b/vdagent/display_configuration.cpp @@ -700,7 +700,9 @@ CCD::~CCD() bool CCD::query_display_config() { LONG query_error(ERROR_SUCCESS); - + if (!get_config_buffers()) { + return false; + } //Until we get it or error != ERROR_INSUFFICIENT_BUFFER do { query_error = _pfnQueryDisplayConfig(QDC_ALL_PATHS, &_numPathElements, _pPathInfo, @@ -711,9 +713,9 @@ bool CCD::query_display_config() //(see https://msdn.microsoft.com/en-us/library/windows/hardware/ff569215(v=vs.85).aspx ) if (query_error) { if (query_error == ERROR_INSUFFICIENT_BUFFER) { - free_config_buffers(); - if (!get_config_buffers()) + if (!get_config_buffers()) { return false; + } } else { vd_printf("%s failed QueryDisplayConfig with 0x%lx", __FUNCTION__, query_error); return false; -- 2.7.4 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel