Initialize buffers before querying display config

The buffers and buffer sizes should be initialized and allocated. This
patch fixes 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 because it is called
inside get_config_buffers.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Sameeh Jubran 2016-08-30 15:41:00 +03:00 committed by Frediano Ziglio
parent efcd07af8b
commit 3856b1147a

View File

@ -356,7 +356,8 @@ 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,
@ -367,7 +368,6 @@ 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())
return false;
} else {