From 8c1bb8bed1b161a604683e866389548002c6c2d1 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sat, 16 May 2015 10:17:19 +0000 Subject: [PATCH] [PCIX] Don't mess up with the stack nor leak resources svn path=/trunk/; revision=67763 --- reactos/drivers/bus/pcix/pci/id.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/bus/pcix/pci/id.c b/reactos/drivers/bus/pcix/pci/id.c index ec03fdf1356..9053e391301 100644 --- a/reactos/drivers/bus/pcix/pci/id.c +++ b/reactos/drivers/bus/pcix/pci/id.c @@ -126,11 +126,13 @@ PciIdPrintf(IN PPCI_ID_BUFFER IdBuffer, 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 @@ PciIdPrintfAppend(IN PPCI_ID_BUFFER IdBuffer, 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 @@ PciIdPrintfAppend(IN PPCI_ID_BUFFER IdBuffer, 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 */