Bug 1142716 - update/tests/TestAUSHelper.cpp CheckMsg leaks |inFP| and |mbuf|. r=bbondy

This commit is contained in:
Robert Strong 2015-03-18 16:25:05 -07:00
Родитель efb4af18cb
Коммит 2dc35d42a4
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -99,11 +99,15 @@ CheckMsg(const NS_tchar *path, const char *expected)
struct stat ms; struct stat ms;
if (fstat(fileno(inFP), &ms)) { if (fstat(fileno(inFP), &ms)) {
fclose(inFP);
inFP = nullptr;
return false; return false;
} }
char *mbuf = (char *) malloc(ms.st_size + 1); char *mbuf = (char *) malloc(ms.st_size + 1);
if (!mbuf) { if (!mbuf) {
fclose(inFP);
inFP = nullptr;
return false; return false;
} }
@ -113,14 +117,19 @@ CheckMsg(const NS_tchar *path, const char *expected)
r -= c; r -= c;
rb += c; rb += c;
if (c == 0 && r) { if (c == 0 && r) {
free(mbuf);
fclose(inFP);
inFP = nullptr;
return false; return false;
} }
mbuf[ms.st_size] = '\0'; mbuf[ms.st_size] = '\0';
rb = mbuf; rb = mbuf;
bool isMatch = strcmp(rb, expected) == 0;
free(mbuf);
fclose(inFP); fclose(inFP);
inFP = nullptr; inFP = nullptr;
return strcmp(rb, expected) == 0; return isMatch;
} }
#ifdef XP_WIN #ifdef XP_WIN