diff --git a/debian/patches/0003-Fix-cppcheck-errors.patch b/debian/patches/0003-Fix-cppcheck-errors.patch
new file mode 100644
index 0000000000000000000000000000000000000000..040266af50d61e34906f0fc02b0c85b31846a33e
--- /dev/null
+++ b/debian/patches/0003-Fix-cppcheck-errors.patch
@@ -0,0 +1,272 @@
+From: Thomas Moulard <thomas.moulard@gmail.com>
+Date: Fri, 19 Apr 2013 11:17:47 +0900
+Subject: Fix cppcheck errors.
+
+Fix various leaked file descriptors, memory and other minor errors
+detected by cppheck.
+
+Origin: upstream, https://gforge.inria.fr/tracker/?func=detail&atid=1867&aid=15623&group_id=397
+Bug: https://gforge.inria.fr/tracker/?func=detail&atid=1867&aid=15623&group_id=397
+Author: Fabien Spindler
+---
+ src/device/framegrabber/1394/vp1394TwoGrabber.cpp |    5 ++-
+ src/image/vpImageIo.cpp                           |   50 ++++++++++++++++++---
+ src/math/matrix/vpMatrix.cpp                      |    2 +
+ src/math/matrix/vpMatrix_svd.cpp                  |    3 ++
+ src/math/spline/vpNurbs.cpp                       |    6 ++-
+ src/robot/real-robot/afma6/vpAfma6.cpp            |    1 -
+ src/robot/real-robot/viper/vpViper650.cpp         |    1 -
+ src/robot/real-robot/viper/vpViper850.cpp         |    1 -
+ 8 files changed, 56 insertions(+), 13 deletions(-)
+
+diff --git a/src/device/framegrabber/1394/vp1394TwoGrabber.cpp b/src/device/framegrabber/1394/vp1394TwoGrabber.cpp
+index f879b2b..e9da6c4 100644
+--- a/src/device/framegrabber/1394/vp1394TwoGrabber.cpp
++++ b/src/device/framegrabber/1394/vp1394TwoGrabber.cpp
+@@ -2831,10 +2831,11 @@ vp1394TwoGrabber::printCameraInfo()
+ 
+   dc1394featureset_t features;
+ #ifdef VISP_HAVE_DC1394_2_CAMERA_ENUMERATE // new API > libdc1394-2.0.0-rc7
+-  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS) {
++  if (dc1394_feature_get_all(camera, &features) != DC1394_SUCCESS)
+ #elif defined VISP_HAVE_DC1394_2_FIND_CAMERAS // old API <= libdc1394-2.0.0-rc7
+-  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS) {
++  if (dc1394_get_camera_feature_set(camera, &features) != DC1394_SUCCESS)
+ #endif
++  {
+     close();
+     vpERROR_TRACE("unable to get feature set for camera %d\n", camera_id);
+     throw (vpFrameGrabberException(vpFrameGrabberException::initializationError,
+diff --git a/src/image/vpImageIo.cpp b/src/image/vpImageIo.cpp
+index 84726e7..f50a22d 100644
+--- a/src/image/vpImageIo.cpp
++++ b/src/image/vpImageIo.cpp
+@@ -2098,13 +2098,19 @@ vpImageIo::writePNG(const vpImage<unsigned char> &I, const char *filename)
+   if (!png_ptr)
+   {
+     fclose (file);
++    vpERROR_TRACE("Error during png_create_write_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG write error")) ;
+   }
+ 
+   png_infop info_ptr = png_create_info_struct(png_ptr);
+   if (!info_ptr)
+   {
+     fclose (file);
+-    png_destroy_write_struct (&png_ptr, &info_ptr);
++    png_destroy_write_struct (&png_ptr, NULL);
++    vpERROR_TRACE("Error during png_create_info_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG write error")) ;
+   }
+ 
+   /* initialize the setjmp for returning properly after a libpng error occured */
+@@ -2161,6 +2167,10 @@ vpImageIo::writePNG(const vpImage<unsigned char> &I, const char *filename)
+   {
+     fclose (file);
+     png_destroy_write_struct (&png_ptr, &info_ptr);
++    for(unsigned int j = 0; j < height; j++)
++      delete[] row_ptrs[j];
++
++    delete[] row_ptrs;
+     vpERROR_TRACE("Error during write image\n");
+     throw (vpImageException(vpImageException::ioError,
+            "PNG write error")) ;
+@@ -2172,6 +2182,10 @@ vpImageIo::writePNG(const vpImage<unsigned char> &I, const char *filename)
+   {
+     fclose (file);
+     png_destroy_write_struct (&png_ptr, &info_ptr);
++    for(unsigned int j = 0; j < height; j++)
++      delete[] row_ptrs[j];
++
++    delete[] row_ptrs;
+     vpERROR_TRACE("Error during write end\n");
+     throw (vpImageException(vpImageException::ioError,
+            "PNG write error")) ;
+@@ -2180,9 +2194,9 @@ vpImageIo::writePNG(const vpImage<unsigned char> &I, const char *filename)
+   png_write_end(png_ptr, NULL);
+ 
+   for(unsigned int j = 0; j < height; j++)
+-    delete[] /*(png_byte)*/row_ptrs[j];
++    delete[] row_ptrs[j];
+ 
+-  delete[] (png_bytep)row_ptrs;
++  delete[] row_ptrs;
+ 
+   png_destroy_write_struct (&png_ptr, &info_ptr);
+ 
+@@ -2236,13 +2250,19 @@ vpImageIo::writePNG(const vpImage<vpRGBa> &I, const char *filename)
+   if (!png_ptr)
+   {
+     fclose (file);
++    vpERROR_TRACE("Error during png_create_write_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG write error")) ;
+   }
+ 
+   png_infop info_ptr = png_create_info_struct(png_ptr);
+   if (!info_ptr)
+   {
+     fclose (file);
+-    png_destroy_write_struct (&png_ptr, &info_ptr);
++    png_destroy_write_struct (&png_ptr, NULL);
++    vpERROR_TRACE("Error during png_create_info_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG write error")) ;
+   }
+ 
+   /* initialize the setjmp for returning properly after a libpng error occured */
+@@ -2301,6 +2321,10 @@ vpImageIo::writePNG(const vpImage<vpRGBa> &I, const char *filename)
+   {
+     fclose (file);
+     png_destroy_write_struct (&png_ptr, &info_ptr);
++    for(unsigned int j = 0; j < height; j++)
++      delete[] row_ptrs[j];
++
++    delete[] row_ptrs;
+     vpERROR_TRACE("Error during write image\n");
+     throw (vpImageException(vpImageException::ioError,
+            "PNG write error")) ;
+@@ -2312,6 +2336,10 @@ vpImageIo::writePNG(const vpImage<vpRGBa> &I, const char *filename)
+   {
+     fclose (file);
+     png_destroy_write_struct (&png_ptr, &info_ptr);
++    for(unsigned int j = 0; j < height; j++)
++      delete[] row_ptrs[j];
++
++    delete[] row_ptrs;
+     vpERROR_TRACE("Error during write end\n");
+     throw (vpImageException(vpImageException::ioError,
+            "PNG write error")) ;
+@@ -2320,9 +2348,9 @@ vpImageIo::writePNG(const vpImage<vpRGBa> &I, const char *filename)
+   png_write_end(png_ptr, NULL);
+ 
+   for(unsigned int j = 0; j < height; j++)
+-    delete[] /*(png_byte)*/row_ptrs[j];
++    delete[] row_ptrs[j];
+ 
+-  delete[] (png_bytep)row_ptrs;
++  delete[] row_ptrs;
+ 
+   png_destroy_write_struct (&png_ptr, &info_ptr);
+ 
+@@ -2611,8 +2639,10 @@ vpImageIo::readPNG(vpImage<vpRGBa> &I, const char *filename)
+   /* check for valid magic number */
+   if (png_sig_cmp (magic,0, sizeof (magic)))
+   {
+-    fprintf (stderr, "error: \"%s\" is not a valid PNG image!\n",filename);
+     fclose (file);
++    vpERROR_TRACE("error: \"%s\" is not a valid PNG image!\n",filename);
++    throw (vpImageException(vpImageException::ioError,
++           "PNG read error")) ;
+   }
+ 
+   /* create a png read struct */
+@@ -2620,6 +2650,9 @@ vpImageIo::readPNG(vpImage<vpRGBa> &I, const char *filename)
+   if (!png_ptr)
+   {
+     fclose (file);
++    vpERROR_TRACE("Error during png_create_read_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG read error")) ;
+   }
+ 
+   /* create a png info struct */
+@@ -2628,6 +2661,9 @@ vpImageIo::readPNG(vpImage<vpRGBa> &I, const char *filename)
+   {
+     fclose (file);
+     png_destroy_read_struct (&png_ptr, NULL, NULL);
++    vpERROR_TRACE("Error during png_create_info_struct()\n");
++    throw (vpImageException(vpImageException::ioError,
++           "PNG read error")) ;
+   }
+ 
+   /* initialize the setjmp for returning properly after a libpng error occured */
+diff --git a/src/math/matrix/vpMatrix.cpp b/src/math/matrix/vpMatrix.cpp
+index cf8c003..628f505 100644
+--- a/src/math/matrix/vpMatrix.cpp
++++ b/src/math/matrix/vpMatrix.cpp
+@@ -201,6 +201,7 @@ void vpMatrix::resize(const unsigned int nrows, const unsigned int ncols,
+     this->data = (double*)realloc(this->data, this->dsize*sizeof(double));
+     if ((NULL == this->data) && (0 != this->dsize))
+     {
++      if (copyTmp != NULL) delete [] copyTmp;
+       vpERROR_TRACE("\n\t\tMemory allocation error when allocating data") ;
+       throw(vpException(vpException::memoryAllocationError,
+         "\n\t\t Memory allocation error when "
+@@ -212,6 +213,7 @@ void vpMatrix::resize(const unsigned int nrows, const unsigned int ncols,
+     this->rowPtrs = (double**)realloc (this->rowPtrs, this->trsize*sizeof(double*));
+     if ((NULL == this->rowPtrs) && (0 != this->dsize))
+     {
++      if (copyTmp != NULL) delete [] copyTmp;
+       vpERROR_TRACE("\n\t\tMemory allocation error when allocating rowPtrs") ;
+       throw(vpException(vpException::memoryAllocationError,
+         "\n\t\t Memory allocation error when "
+diff --git a/src/math/matrix/vpMatrix_svd.cpp b/src/math/matrix/vpMatrix_svd.cpp
+index 9ae504d..4db44db 100644
+--- a/src/math/matrix/vpMatrix_svd.cpp
++++ b/src/math/matrix/vpMatrix_svd.cpp
+@@ -128,6 +128,9 @@ void vpMatrix::svdNr(vpColVector& W, vpMatrix& V)
+ 
+   if (m < n)
+   {
++    delete[] w;
++    delete[] a;
++    delete[] v;
+     vpERROR_TRACE("\n\t\tSVDcmp: You must augment A with extra zero rows") ;
+     throw(vpMatrixException(vpMatrixException::matrixError,
+ 			    "\n\t\tSVDcmp: You must augment A with "
+diff --git a/src/math/spline/vpNurbs.cpp b/src/math/spline/vpNurbs.cpp
+index cc55f37..4d61a5c 100644
+--- a/src/math/spline/vpNurbs.cpp
++++ b/src/math/spline/vpNurbs.cpp
+@@ -627,7 +627,11 @@ vpNurbs::removeCurveKnot(double l_u, unsigned int l_r, unsigned int l_num, doubl
+     first--;
+     last++;
+   }
+-  if (t == 0) return t;
++  if (t == 0) {
++    delete[] tempP;
++    delete[] tempW;
++    return t;
++  }
+   for(unsigned int k = l_r+1; k <= m; k++) l_knots[k-t] = l_knots[k];
+   j = (unsigned int)fout;
+   i = j;
+diff --git a/src/robot/real-robot/afma6/vpAfma6.cpp b/src/robot/real-robot/afma6/vpAfma6.cpp
+index 6719d31..ed638c1 100644
+--- a/src/robot/real-robot/afma6/vpAfma6.cpp
++++ b/src/robot/real-robot/afma6/vpAfma6.cpp
+@@ -1066,7 +1066,6 @@ vpAfma6::parseConfigFile (const char * filename)
+   {
+     vpERROR_TRACE ("Impossible to read the config file %s.",
+                    filename);
+-    fclose(fdtask);
+     throw vpRobotException (vpRobotException::readingParametersError,
+                             "Impossible to read the config file.");
+   }
+diff --git a/src/robot/real-robot/viper/vpViper650.cpp b/src/robot/real-robot/viper/vpViper650.cpp
+index c0200a6..36a0040 100644
+--- a/src/robot/real-robot/viper/vpViper650.cpp
++++ b/src/robot/real-robot/viper/vpViper650.cpp
+@@ -430,7 +430,6 @@ vpViper650::parseConfigFile (const char * filename)
+   {
+     vpERROR_TRACE ("Impossible to read the config file %s.",
+                    filename);
+-    fclose(fdtask);
+     throw vpRobotException (vpRobotException::readingParametersError,
+                             "Impossible to read the config file.");
+   }
+diff --git a/src/robot/real-robot/viper/vpViper850.cpp b/src/robot/real-robot/viper/vpViper850.cpp
+index 2ae8bfe..c23007b 100644
+--- a/src/robot/real-robot/viper/vpViper850.cpp
++++ b/src/robot/real-robot/viper/vpViper850.cpp
+@@ -430,7 +430,6 @@ vpViper850::parseConfigFile (const char * filename)
+   {
+     vpERROR_TRACE ("Impossible to read the config file %s.",
+                    filename);
+-    fclose(fdtask);
+     throw vpRobotException (vpRobotException::readingParametersError,
+                             "Impossible to read the config file.");
+   }
diff --git a/debian/patches/series b/debian/patches/series
index 5cd7c04a7b60211e25f61560482d30bbe808f81b..91c743f5c718e349050f88f661dfb0dd4b5bcbd8 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0001-Fix-library-soversion.patch
 0002-Use-pkg-config-to-retrieve-dependencies.patch
+0003-Fix-cppcheck-errors.patch