[gmime] Fixed a bug in multipart insertion
- From: Jeffrey Stedfast <fejj src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gmime] Fixed a bug in multipart insertion
- Date: Thu, 5 Nov 2009 16:12:31 +0000 (UTC)
commit 2a22ae0b15d21fc8b004aba5637a8651d37a4c15
Author: Jeffrey Stedfast <fejj gnome org>
Date: Thu Nov 5 11:11:19 2009 -0500
Fixed a bug in multipart insertion
2009-11-05 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-multipart.c (ptr_array_insert): Fixed to handle an
index larger than the current array length as well as fixing the
true insert case to shift items when index is les than the current
array length (as opposed to when it is equal-to). Thanks to
harven gingers rulez pl for finding this bug.
ChangeLog | 8 ++++++++
gmime/gmime-multipart.c | 14 ++++++++------
2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fcde714..c53bd6d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-05 Jeffrey Stedfast <fejj novell com>
+
+ * gmime/gmime-multipart.c (ptr_array_insert): Fixed to handle an
+ index larger than the current array length as well as fixing the
+ true insert case to shift items when index is les than the current
+ array length (as opposed to when it is equal-to). Thanks to
+ harven gingers rulez pl for finding this bug.
+
2009-10-10 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-utils.c: Fixed the military timezone offsets.
diff --git a/gmime/gmime-multipart.c b/gmime/gmime-multipart.c
index dae0e33..b66ba4c 100644
--- a/gmime/gmime-multipart.c
+++ b/gmime/gmime-multipart.c
@@ -495,18 +495,20 @@ ptr_array_insert (GPtrArray *array, guint index, gpointer object)
unsigned char *dest, *src;
guint n;
- g_ptr_array_set_size (array, array->len + 1);
-
- if (index == array->len) {
- /* need to move items down */
+ if (index < array->len) {
+ /* need to shift some items */
+ g_ptr_array_set_size (array, array->len + 1);
+
dest = ((unsigned char *) array->pdata) + (sizeof (void *) * (index + 1));
src = ((unsigned char *) array->pdata) + (sizeof (void *) * index);
n = array->len - index - 1;
g_memmove (dest, src, (sizeof (void *) * n));
+ array->pdata[index] = object;
+ } else {
+ /* the easy case */
+ g_ptr_array_add (array, object);
}
-
- array->pdata[index] = object;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]