- Added some tools to detect memory leaks.
[ircu2.10.12-pk.git] / ircd / motd.c
index fe78046d376f944eb54307f1d90b9ab3119d3b5a..393d1ee4c1d2768ce6ed243c75e1aa57027724a9 100644 (file)
@@ -156,9 +156,11 @@ motd_cache(struct Motd *motd)
   fbclose(file); /* close the file */
 
   /* trim memory usage a little */
-  motd->cache = (struct MotdCache *)MyRealloc(cache, sizeof(struct MotdCache) +
-                                             (MOTD_LINESIZE *
-                                              (cache->count - 1)));
+  motd->cache = (struct MotdCache*)MyMalloc(sizeof(struct MotdCache) +
+                                            (MOTD_LINESIZE * (cache->count - 1)));
+  memcpy(motd->cache, cache, sizeof(struct MotdCache) +
+         (MOTD_LINESIZE * (cache->count - 1)));
+  MyFree(cache);
 
   /* now link it in... */
   motd->cache->next = MotdList.cachelist;