File: 05_fix-alloc

package info (click to toggle)
tetradraw 2.0.3-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,072 kB
  • sloc: sh: 7,102; ansic: 6,509; makefile: 28
file content (23 lines) | stat: -rw-r--r-- 612 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Author: Michael Griffin <mrmisticismo@hotmail.com>	vim:ft=diff:
Description: fix alloc size


--- a/src/internal.c
+++ b/src/internal.c
@@ -25,7 +25,7 @@
  * it makes sure that malloc doesnt return NULL */
 void *m_malloc(size_t size) {
 	void *p = (void *)NULL;
-	p = malloc(size);
+	p = malloc(size * sizeof(int32_t));
 	if (!p) {
 		fprintf(stderr, "ERROR: malloc of %d bytes failed\n", size);
 		fprintf(stderr, "Exiting...\n");
@@ -49,6 +49,6 @@
 
 /* this is a wrapper for realloc */
 void *m_realloc(void *p, size_t size) {
-	p = realloc(p, size);
+	p = realloc(p, size * sizeof(int32_t));
 	return p;
 }