Hi Luca,
 
Here a simple patch (against latest CVS) to check malloc return codes in the RRD dumps 
in rrdPlugin.c and handle them gracefully. 
 
- Robbert
 
--- ntop/plugins/rrdPlugin.c.orig 2004-06-18 09:11:17.000000000 +0200
+++ ntop/plugins/rrdPlugin.c 2004-06-21 14:37:32.726575360 +0200
@@ -1859,12 +1859,20 @@
  // save this as it may change
  maxHosts = myGlobals.device[devIdx].hostsno;
  len = sizeof(DomainStats)*maxHosts;
- tmpStats = (DomainStats*)malloc(len);
- memset(tmpStats, 0, len);
+ tmpStats = (DomainStats*)mallocAndInitWithReportWarn(len,"rrdMainLoop");
 
- len = sizeof(DomainStats**)*maxHosts;
- stats = (DomainStats**)malloc(len);
- memset(stats, 0, len);
+ if (tmpStats == NULL) {
+          traceEvent(CONST_TRACE_WARNING, "RRD: Out of memory, skipping domain RRD 
dumps");
+   continue;
+ }
+
+ len = sizeof(DomainStats*)*maxHosts;
+ stats = (DomainStats**)mallocAndInitWithReportWarn(len,"rrdMainLoop(2)");
+
+ if (stats == NULL) {
+          traceEvent(CONST_TRACE_WARNING, "RRD: Out of memory, skipping domain RRD 
dumps");
+   continue;
+ }
 
  // walk through all hosts, getting their domain names and counting stats
  for (el = getFirstHost(devIdx); 

Attachment: rrdplugin-malloc-returncode-fix.diff
Description: rrdplugin-malloc-returncode-fix.diff

_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to