From: notaz <notasas@gmail.com>
Date: Sat, 30 Sep 2017 23:42:24 +0000 (+0300)
Subject: fix underalloc
X-Git-Tag: v1.92~15
X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f80007bcc94faae7c369d4ed8a07a9d35c31c72;p=picodrive.git

fix underalloc
---

diff --git a/pico/sek.c b/pico/sek.c
index 8bf0341b..51765287 100644
--- a/pico/sek.c
+++ b/pico/sek.c
@@ -302,7 +302,8 @@ void SekRegisterIdleHit(unsigned int pc)
 
 void SekInitIdleDet(void)
 {
-  unsigned short **tmp = realloc(idledet_ptrs, 0x200*4);
+  unsigned short **tmp;
+  tmp = realloc(idledet_ptrs, 0x200 * sizeof(tmp[0]));
   if (tmp == NULL) {
     free(idledet_ptrs);
     idledet_ptrs = NULL;
@@ -410,7 +411,8 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx)
   }
 
   if (idledet_count >= 0x200 && (idledet_count & 0x1ff) == 0) {
-    unsigned short **tmp = realloc(idledet_ptrs, (idledet_count+0x200)*4);
+    unsigned short **tmp;
+    tmp = realloc(idledet_ptrs, (idledet_count+0x200) * sizeof(tmp[0]));
     if (tmp == NULL)
       return 1;
     idledet_ptrs = tmp;