summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-02 21:52:38 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-02 21:52:38 +0000
commit21cef58bc1b46ba4d5e7371463920c7744904d32 (patch)
tree3032e5f6c1ba77c4f073a88fd9ca464c0babb76e
parent94790fef4a846ef2bed9bf1825c4c2b0ca7b8566 (diff)
2003-04-02 Havoc Pennington <hp@redhat.com>
* dbus/dbus-string.c (set_length): fix a bug - we allocated max of current alloc and needed new length, not max of the doubled allocation and needed new length. Also, when building tests, don't do the double-allocation stuff, just realloc every time.
-rw-r--r--ChangeLog7
-rw-r--r--dbus/dbus-string.c11
2 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e72e8a6d..2340ba96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2003-04-02 Havoc Pennington <hp@redhat.com>
+ * dbus/dbus-string.c (set_length): fix a bug - we allocated max of
+ current alloc and needed new length, not max of the doubled
+ allocation and needed new length. Also, when building tests,
+ don't do the double-allocation stuff, just realloc every time.
+
+2003-04-02 Havoc Pennington <hp@redhat.com>
+
* dbus/dbus-sysdeps.c (_dbus_file_get_contents): include filenames
in error messages
(_dbus_string_get_dirname): new
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index dd5781fa..0bd754b3 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -361,8 +361,17 @@ set_length (DBusRealString *real,
else
new_allocated = real->allocated * 2;
+ /* if you change the code just above here, run the tests without
+ * the following before you commit
+ */
+#ifdef DBUS_BUILD_TESTS
+ new_allocated = 0; /* ensure a realloc every time so that we go
+ * through all malloc failure codepaths
+ */
+#endif
+
/* But be sure we always alloc at least space for the new length */
- new_allocated = MAX (real->allocated, new_length + ALLOCATION_PADDING);
+ new_allocated = MAX (new_allocated, new_length + ALLOCATION_PADDING);
new_str = dbus_realloc (real->str - real->align_offset, new_allocated);
if (new_str == NULL)