[Pkg-privacy-commits] [libotr] 13/225: * src/mem.c: Don't do arithmetic on void pointers.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:44:45 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository libotr.
commit 98617d5f3ac0e62d7a044c4491a18a66e20137fe
Author: cypherpunk <cypherpunk>
Date: Thu Aug 4 16:52:11 2005 +0000
* src/mem.c: Don't do arithmetic on void pointers.
---
ChangeLog | 2 ++
src/mem.c | 10 +++++-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 54ce80f..2dc941a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@
* src/message.c (otrl_message_receiving): Handle fragments in
received messages.
+ * src/mem.c: Don't do arithmetic on void pointers.
+
2005-07-29
* src/message.h:
diff --git a/src/mem.c b/src/mem.c
index 574258e..d525577 100644
--- a/src/mem.c
+++ b/src/mem.c
@@ -63,7 +63,7 @@ static void *otrl_mem_malloc(size_t n)
((size_t *)p)[1] = OTRL_MEM_MAGIC;
#endif
- return (p + header_size);
+ return (void *)((char *)p + header_size);
}
static int otrl_mem_is_secure(const void *p)
@@ -73,7 +73,7 @@ static int otrl_mem_is_secure(const void *p)
static void otrl_mem_free(void *p)
{
- void *real_p = p - header_size;
+ void *real_p = (void *)((char *)p - header_size);
size_t n = ((size_t *)real_p)[0];
#ifdef OTRL_MEM_MAGIC
if (((size_t *)real_p)[1] != OTRL_MEM_MAGIC) {
@@ -100,7 +100,7 @@ static void *otrl_mem_realloc(void *p, size_t n)
otrl_mem_free(p);
return NULL;
} else {
- void *real_p = p - header_size;
+ void *real_p = (void *)((char *)p - header_size);
void *new_p;
size_t old_n = ((size_t *)real_p)[0];
#ifdef OTRL_MEM_MAGIC
@@ -121,7 +121,7 @@ static void *otrl_mem_realloc(void *p, size_t n)
if (new_n < old_n) {
/* Overwrite the space we're about to stop using */
- void *p = real_p + new_n;
+ void *p = (void *)((char *)real_p + new_n);
size_t excess = old_n - new_n;
memset(p, 0xff, excess);
memset(p, 0xaa, excess);
@@ -136,7 +136,7 @@ static void *otrl_mem_realloc(void *p, size_t n)
}
((size_t *)new_p)[0] = new_n; /* Includes header size */
- return (new_p + header_size);
+ return (void *)((char *)new_p + header_size);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git
More information about the Pkg-privacy-commits
mailing list