Commit 63b7d9d1 authored by Olivier Bertrand's avatar Olivier Bertrand

Fix MDEV-12631 valgrind warning for zipped tables

  modified:   storage/connect/filamzip.cpp
parent a091314d
/*********** File AM Zip C++ Program Source Code File (.CPP) ***********/ /*********** File AM Zip C++ Program Source Code File (.CPP) ***********/
/* PROGRAM NAME: FILAMZIP */ /* PROGRAM NAME: FILAMZIP */
/* ------------- */ /* ------------- */
/* Version 1.1 */ /* Version 1.2 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
...@@ -652,12 +652,18 @@ bool UNZIPUTL::openEntry(PGLOBAL g) ...@@ -652,12 +652,18 @@ bool UNZIPUTL::openEntry(PGLOBAL g)
} // endif rc } // endif rc
size = finfo.uncompressed_size; size = finfo.uncompressed_size;
memory = new char[size + 1];
try {
memory = new char[size + 1];
} catch (...) {
strcpy(g->Message, "Out of memory");
return true;
} // end try/catch
if ((rc = unzReadCurrentFile(zipfile, memory, size)) < 0) { if ((rc = unzReadCurrentFile(zipfile, memory, size)) < 0) {
sprintf(g->Message, "unzReadCurrentFile rc = %d", rc); sprintf(g->Message, "unzReadCurrentFile rc = %d", rc);
unzCloseCurrentFile(zipfile); unzCloseCurrentFile(zipfile);
free(memory); delete[] memory;
memory = NULL; memory = NULL;
entryopen = false; entryopen = false;
} else { } else {
...@@ -682,7 +688,7 @@ void UNZIPUTL::closeEntry() ...@@ -682,7 +688,7 @@ void UNZIPUTL::closeEntry()
} // endif entryopen } // endif entryopen
if (memory) { if (memory) {
free(memory); delete[] memory;
memory = NULL; memory = NULL;
} // endif memory } // endif memory
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment