diff --git a/inc/V4l2DeviceSource.h b/inc/V4l2DeviceSource.h index fe9ea42..e73966f 100644 --- a/inc/V4l2DeviceSource.h +++ b/inc/V4l2DeviceSource.h @@ -36,6 +36,8 @@ class V4L2DeviceSource: public FramedSource struct Frame { Frame(char* buffer, int size, timeval timestamp) : m_buffer(buffer), m_size(size), m_timestamp(timestamp) {}; + Frame(const Frame&); + Frame& operator=(const Frame&); ~Frame() { delete m_buffer; }; char* m_buffer; diff --git a/src/V4l2DeviceSource.cpp b/src/V4l2DeviceSource.cpp index d7c7b50..b712fd9 100644 --- a/src/V4l2DeviceSource.cpp +++ b/src/V4l2DeviceSource.cpp @@ -149,7 +149,7 @@ void V4L2DeviceSource::deliverFrame() } fFrameSize -= offset; memcpy(fTo, frame->m_buffer+offset, fFrameSize); - delete frame; + delete [] frame; } // send Frame to the consumer @@ -168,13 +168,13 @@ void V4L2DeviceSource::getNextFrame() if (frameSize < 0) { envir() << "V4L2DeviceSource::getNextFrame errno:" << errno << " " << strerror(errno) << "\n"; - delete buffer; + delete [] buffer; handleClosure(this); } else if (frameSize == 0) { envir() << "V4L2DeviceSource::getNextFrame no data errno:" << errno << " " << strerror(errno) << "\n"; - delete buffer; + delete [] buffer; } else { @@ -192,6 +192,10 @@ void V4L2DeviceSource::getNextFrame() { queueFrame(buffer,frameSize,ref); } + else + { + delete [] buffer; + } } } @@ -263,7 +267,6 @@ bool V4L2DeviceSource::processConfigrationFrame(char * frame, int frameSize) std::cout << "AuxLine:" << m_auxLine << " \n"; } ret = true; - delete [] frame; } }