Почему valgrind говорит, что у меня есть утечка памяти при вызове fclose()
?Valgrind обнаруживает утечку памяти при fclose()
#include <stdio.h>
class Stream
{
public:
Stream();
~Stream();
private:
char* pszOutput;
size_t size;
FILE* file;
};
Stream::Stream()
{
file = open_memstream(&pszOutput, &size);
}
Stream::~Stream()
{
fclose(file);
}
int main()
{
Stream s;
return 0;
}
Valgrind отчет:
==52387== 1 bytes in 1 blocks are definitely lost in loss record 1 of 1
==52387== at 0x4C28CCE: realloc (vg_replace_malloc.c:632)
==52387== by 0x5639CA3: _IO_mem_finish (memstream.c:132)
==52387== by 0x5635956: [email protected]@GLIBC_2.2.5 (iofclose.c:66)
Имеет ли значение для инициализации pszOutput
или size
? Или, может быть, мне нужно добавить что-то еще?
Вы пытались освободить (pszOutput); ? – willll