summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2010-03-29 20:51:48 -0700
committerElliott Hughes <enh@google.com>2010-03-29 20:51:48 -0700
commit7ca6fd0dca02f7abdd8808db78357743bbdd23a5 (patch)
treeb44b5d779ad41c1ba367c95764b5d8fefaa26836 /include
parent3314eef71dbd0ed6d8aa96fb99432ff125cc4121 (diff)
downloadlibcore-7ca6fd0dca02f7abdd8808db78357743bbdd23a5.zip
libcore-7ca6fd0dca02f7abdd8808db78357743bbdd23a5.tar.gz
libcore-7ca6fd0dca02f7abdd8808db78357743bbdd23a5.tar.bz2
Fix a bug, and protect against an unrelated class of bugs.
If the Java array allocation in InetAddress.cpp failed, we'd free NULL instead of the previously-allocated structure. This is a new bug in froyo, but only happens in out of memory situations, so doesn't seem worth fixing there. Unrelatedly, let's disallow assignment and copying of all our RAII classes. This isn't a mistake I've seen made, but it's easy to protect against, so we may as well do so consistently. Change-Id: I2433b31ff983d388788b09e59e08d661f1725ecd
Diffstat (limited to 'include')
-rw-r--r--include/LocalArray.h4
-rw-r--r--include/ScopedByteArray.h4
-rw-r--r--include/ScopedFd.h4
3 files changed, 12 insertions, 0 deletions
diff --git a/include/LocalArray.h b/include/LocalArray.h
index 74c9085..2ab708a 100644
--- a/include/LocalArray.h
+++ b/include/LocalArray.h
@@ -66,6 +66,10 @@ private:
char mOnStackBuffer[STACK_BYTE_COUNT];
char* mPtr;
size_t mSize;
+
+ // Disallow copy and assignment.
+ LocalArray(const LocalArray&);
+ void operator=(const LocalArray&);
};
#endif // LOCAL_ARRAY_H_included
diff --git a/include/ScopedByteArray.h b/include/ScopedByteArray.h
index bcbee99..6955b70 100644
--- a/include/ScopedByteArray.h
+++ b/include/ScopedByteArray.h
@@ -48,6 +48,10 @@ private:
JNIEnv* mEnv;
jbyteArray mByteArray;
jbyte* mBytes;
+
+ // Disallow copy and assignment.
+ ScopedByteArray(const ScopedByteArray&);
+ void operator=(const ScopedByteArray&);
};
#endif // SCOPED_BYTE_ARRAY_H_included
diff --git a/include/ScopedFd.h b/include/ScopedFd.h
index 30feabd..d2b7935 100644
--- a/include/ScopedFd.h
+++ b/include/ScopedFd.h
@@ -37,6 +37,10 @@ public:
private:
int fd;
+
+ // Disallow copy and assignment.
+ ScopedFd(const ScopedFd&);
+ void operator=(const ScopedFd&);
};
#endif // SCOPED_FD_H_included