summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKris De Gussem <kris.degussem@gmail.com>2011-11-19 18:50:23 +0000
committerKris <Kris.De.Gussem@hotmail.com>2011-11-19 18:50:23 +0000
commit7d09a4c6f251d24bd87f3c786e835e84255bcabf (patch)
tree8a57f4971fda59695087a387e85a720f588bb58d /src
parentcppcheck: initialisation and warning cleanup (diff)
downloadinkscape-7d09a4c6f251d24bd87f3c786e835e84255bcabf.tar.gz
inkscape-7d09a4c6f251d24bd87f3c786e835e84255bcabf.zip
fix pointer usage after releasing memory
(bzr r10745)
Diffstat (limited to 'src')
-rw-r--r--src/io/uristream.cpp20
-rw-r--r--src/io/uristream.h9
2 files changed, 14 insertions, 15 deletions
diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp
index 7397d725f..19994bc82 100644
--- a/src/io/uristream.cpp
+++ b/src/io/uristream.cpp
@@ -98,27 +98,26 @@ UriInputStream::UriInputStream(Inkscape::URI &source)
scheme = SCHEME_FILE;
else if (strncmp("data", schemestr, 4)==0)
scheme = SCHEME_DATA;
- //printf("in schemestr:'%s' scheme:'%d'\n", schemestr, scheme);
- gchar *cpath = NULL;
+ gchar *cpath = NULL;
switch (scheme) {
case SCHEME_FILE:
cpath = uri.toNativeFilename();
- //printf("in cpath:'%s'\n", cpath);
inf = fopen_utf8name(cpath, FILE_READ);
- //inf = fopen(cpath, "rb");
- g_free(cpath);
if (!inf) {
Glib::ustring err = "UriInputStream cannot open file ";
err += cpath;
+ g_free(cpath);
throw StreamException(err);
}
+ else{
+ g_free(cpath);
+ }
break;
case SCHEME_DATA:
data = (unsigned char *) uri.getPath();
- //printf("in data:'%s'\n", data);
dataPos = 0;
dataLen = strlen((const char *)data);
break;
@@ -131,15 +130,18 @@ UriInputStream::UriInputStream(Inkscape::URI &source)
*
*/
UriInputStream::UriInputStream(FILE *source, Inkscape::URI &uri)
- throw (StreamException): inf(source),
- uri(uri)
+ throw (StreamException): uri(uri),
+ inf(source),
+ data(0),
+ dataPos(0),
+ dataLen(0),
+ closed(false)
{
scheme = SCHEME_FILE;
if (!inf) {
Glib::ustring err = "UriInputStream passed NULL";
throw StreamException(err);
}
- closed = false;
}
/**
diff --git a/src/io/uristream.h b/src/io/uristream.h
index 67d2f34d7..16b1b0894 100644
--- a/src/io/uristream.h
+++ b/src/io/uristream.h
@@ -50,18 +50,15 @@ public:
virtual int get() throw(StreamException);
private:
-
- bool closed;
-
+ Inkscape::URI &uri;
FILE *inf; //for file: uris
unsigned char *data; //for data: uris
int dataPos; // current read position in data field
int dataLen; // length of data buffer
-
- Inkscape::URI &uri;
-
+ bool closed;
int scheme;
+
}; // class UriInputStream