From 3116161f5d8849e6f069db11b0f27bbde26e49e9 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Wed, 5 Dec 2012 01:09:05 +0100 Subject: [PATCH] BGA: Fix possible memory leak. --- sortix/bga.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sortix/bga.cpp b/sortix/bga.cpp index 24b17e24..0f01ac8a 100644 --- a/sortix/bga.cpp +++ b/sortix/bga.cpp @@ -303,11 +303,17 @@ bool BGADriver::SwitchMode(const char* mode) { bool result = false; char* modeclone = String::Clone(mode); + if ( !modeclone ) + return NULL; char* xstr = NULL; char* ystr = NULL; char* bppstr = NULL; if ( !ReadParamString(mode, "width", &xstr, "height", &ystr, - "bpp", &bppstr, "STOP") ) { return false; } + "bpp", &bppstr, "STOP") ) + { + delete[] modeclone; + return false; + } uint16_t xres = xstr ? atoi(xstr) : 0; uint16_t yres = ystr ? atoi(ystr) : 0; uint16_t bpp = bppstr ? atoi(bppstr) : 32;