--- libgig/trunk/src/helper.h 2009/03/25 15:20:20 1874 +++ libgig/trunk/src/helper.h 2009/03/26 13:32:59 1875 @@ -2,7 +2,7 @@ * * * libgig - C++ cross-platform Gigasampler format file access library * * * - * Copyright (C) 2003-2006 by Christian Schoenebeck * + * Copyright (C) 2003-2009 by Christian Schoenebeck * * * * * * This library is free software; you can redistribute it and/or modify * @@ -86,6 +86,7 @@ * @param WordSize - size of the data words (in bytes) */ inline void SwapMemoryArea(void* pData, unsigned long AreaSize, uint WordSize) { + if (!AreaSize) return; // AreaSize==0 would cause a segfault here switch (WordSize) { // TODO: unefficient case 1: { uint8_t* pDst = (uint8_t*) pData; @@ -128,7 +129,7 @@ memcpy((uint8_t*) pData + lo, (uint8_t*) pData + hi, WordSize); memcpy((uint8_t*) pData + hi, pCache, WordSize); } - delete[] pCache; + if (pCache) delete[] pCache; break; } }