summaryrefslogtreecommitdiff
path: root/chat/libotr/patches/patch-aa
blob: fff640cbfb94d54c4dfb1a02f1dac6ae292cf90b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$NetBSD: patch-aa,v 1.1 2005/07/30 21:30:53 rillig Exp $

Don't do arithmetic with void pointers.

--- src/mem.c.orig	Fri Jan 21 16:02:03 2005
+++ src/mem.c	Sat Jul 30 23:28:10 2005
@@ -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
 
 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, s
 	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, s
 
 	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, s
 	}
 
 	((size_t *)new_p)[0] = new_n;  /* Includes header size */
-	return (new_p + header_size);
+	return (void *)((char *)new_p + header_size);
     }
 }