]> arthur.barton.de Git - netatalk.git/commitdiff
afpd/colume: fix a couple of memory leaks
authorRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Mon, 11 Feb 2013 21:18:01 +0000 (22:18 +0100)
committerRiccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Mon, 11 Feb 2013 21:18:01 +0000 (22:18 +0100)
Reported by Coverity as CID #201199, #201200.

etc/afpd/volume.c

index 8798635a07678150921e3b5139f54ec942269b73..8867715599df2264df5ddb53a0a6b328b07e2f8e 100644 (file)
@@ -176,13 +176,18 @@ static int get_tm_used(struct vol * restrict vol)
 
             EC_NULL_LOG( infoplist = bformat("%s/%s/%s", vol->v_path, entry->d_name, "Info.plist") );
             
-            if ((bandsize = get_tm_bandsize(cfrombstr(infoplist))) == -1)
+            if ((bandsize = get_tm_bandsize(cfrombstr(infoplist))) == -1) {
+                bdestroy(infoplist);
                 continue;
+            }
 
             EC_NULL_LOG( bandsdir = bformat("%s/%s/%s/", vol->v_path, entry->d_name, "bands") );
 
-            if ((links = get_tm_bands(cfrombstr(bandsdir))) == -1)
+            if ((links = get_tm_bands(cfrombstr(bandsdir))) == -1) {
+                bdestroy(infoplist);
+                bdestroy(bandsdir);
                 continue;
+            }
 
             used += (links - 1) * bandsize;
             LOG(log_debug, logtype_afpd, "getused(\"%s\"): bands: %" PRIu64 " bytes",