Author: pschweitzer Date: Sat May 16 10:17:19 2015 New Revision: 67763
URL: http://svn.reactos.org/svn/reactos?rev=67763&view=rev Log: [PCIX] Don't mess up with the stack nor leak resources
Modified: trunk/reactos/drivers/bus/pcix/pci/id.c
Modified: trunk/reactos/drivers/bus/pcix/pci/id.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/bus/pcix/pci/id.c?r... ============================================================================== --- trunk/reactos/drivers/bus/pcix/pci/id.c [iso-8859-1] (original) +++ trunk/reactos/drivers/bus/pcix/pci/id.c [iso-8859-1] Sat May 16 10:17:19 2015 @@ -126,11 +126,13 @@ ULONG Size, Length; PANSI_STRING AnsiString; va_list va; - va_start(va, Format); + ASSERT(IdBuffer->Count < MAX_ANSI_STRINGS);
/* Do the actual string formatting into the character buffer */ + va_start(va, Format); vsprintf(IdBuffer->CharBuffer, Format, va); + va_end(va);
/* Initialize the ANSI_STRING that will hold this string buffer */ AnsiString = &IdBuffer->Strings[IdBuffer->Count]; @@ -161,7 +163,7 @@ ULONG NextId, Size, Length, MaxLength; PANSI_STRING AnsiString; va_list va; - va_start(va, Format); + ASSERT(IdBuffer->Count);
/* Choose the next static ANSI_STRING to use */ @@ -171,7 +173,9 @@ MaxLength = (PCHAR)(IdBuffer + 1) - IdBuffer->CharBuffer;
/* Do the actual append, and return the length this string took */ + va_start(va, Format); Length = vsprintf(IdBuffer->CharBuffer - 1, Format, va); + va_end(va); ASSERT(Length < MaxLength);
/* Select the static ANSI_STRING, and update its length information */