[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [digikam] libs/dimg: Pass-By-Value, fix possible null pointer
From:       Marcel Wiesweg <marcel.wiesweg () gmx ! de>
Date:       2013-01-31 21:39:20
Message-ID: 20130131213920.2973DA60C8 () git ! kde ! org
[Download RAW message or body]

Git commit 2a064a842b5b6bb37945f004902eb7f5c786ad8a by Marcel Wiesweg.
Committed on 31/01/2013 at 22:32.
Pushed by mwiesweg into branch 'master'.

Pass-By-Value, fix possible null pointer

M  +3    -3    libs/dimg/dimg.cpp
M  +2    -2    libs/dimg/dimg.h

http://commits.kde.org/digikam/2a064a842b5b6bb37945f004902eb7f5c786ad8a

diff --git a/libs/dimg/dimg.cpp b/libs/dimg/dimg.cpp
index 4744191..5991b20 100644
--- a/libs/dimg/dimg.cpp
+++ b/libs/dimg/dimg.cpp
@@ -100,14 +100,14 @@ DImg::DImg()
 }
 
 DImg::DImg(const QByteArray& filePath, DImgLoaderObserver* const observer,
-           DRawDecoding rawDecodingSettings)
+           const DRawDecoding& rawDecodingSettings)
     : m_priv(new DImgPrivate)
 {
     load(filePath, observer, rawDecodingSettings);
 }
 
 DImg::DImg(const QString& filePath, DImgLoaderObserver* const observer,
-           DRawDecoding rawDecodingSettings)
+           const DRawDecoding& rawDecodingSettings)
     : m_priv(new DImgPrivate)
 {
     load(filePath, observer, rawDecodingSettings);
@@ -817,7 +817,7 @@ DImg::FORMAT DImg::fileFormat(const QString& filePath)
         FILE* file = fopen(QFile::encodeName(filePath), "rb");
 
         // FIXME: scanf without field width limits can crash with huge input data
-        if (fscanf(file, "P6 %d %d %d%c", &width, &height, &rgbmax, &nl) == 4)
+        if (file && fscanf(file, "P6 %d %d %d%c", &width, &height, &rgbmax, &nl) == 4)
         {
             if (rgbmax > 255)
             {
diff --git a/libs/dimg/dimg.h b/libs/dimg/dimg.h
index fa5a155..748b2f8 100644
--- a/libs/dimg/dimg.h
+++ b/libs/dimg/dimg.h
@@ -129,12 +129,12 @@ public:
     /** Load image using QByteArray as file path
      */
     explicit DImg(const QByteArray& filePath, DImgLoaderObserver* const observer = 0,
-                  DRawDecoding rawDecodingSettings=DRawDecoding());
+                  const DRawDecoding& rawDecodingSettings=DRawDecoding());
 
     /** Load image using QString as file path
      */
     explicit DImg(const QString& filePath, DImgLoaderObserver* const observer = 0,
-                  DRawDecoding rawDecodingSettings=DRawDecoding());
+                  const DRawDecoding& rawDecodingSettings=DRawDecoding());
 
     /** Copy image: Creates a shallow copy that refers to the same shared data.
         The two images will be equal. Call detach() or copy() to create deep copies.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic