On Tue, 2006-06-27 at 18:18 -0700, Debora Velarde wrote:
> Below is a patch for a double free bug found by Coverity.
> 
> comparison_path may have already been freed

 Did you not run Coverity again, did it not flag the problem after that
change?

 The whole "if (x) free(x);" everywhere in the code is obviously
confusing you, and others :(.

 free(NULL); is valid.
 free(malloc(1)); is valid.
 x = malloc(1); free(x); free(x); is invalid, due to double free is the
malloc() succeeds.
 x = malloc(1); if (x) free(x); if (x) free(x); is still invalid, but
confusing.


 I've attached a patch against 0.5.7.

-- 
James Antill <[EMAIL PROTECTED]>
diff -rup devallocator-orig/progs/devallocator-config.c devallocator/progs/devallocator-config.c
--- devallocator-orig/progs/devallocator-config.c	2006-07-11 17:02:49.000000000 -0400
+++ devallocator/progs/devallocator-config.c	2006-07-13 15:56:11.000000000 -0400
@@ -260,8 +260,8 @@ is_device_unique(struct device_entries *
 			free(comparison_path);
 			break;
 		}
-		if (comparison_path)
-			free(comparison_path);
+		free(comparison_path);
+		comparison_path = NULL;
 		dptr = dptr->next;
 	}
 	free(this_devices_path);
Only in devallocator/progs: devallocator-config.c~

Attachment: signature.asc
Description: This is a digitally signed message part

--
redhat-lspp mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/redhat-lspp

Reply via email to