Check-in Number:
|
5529 | |
Date: |
2006-Jul-28 20:22:43 (local)
2006-Jul-28 18:22:43 (UTC) |
User: | rse |
Branch: | |
Comment: |
Fixed potential memory leak in uuid_create() as spotted by SPLINT. |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/uuid/ChangeLog 1.123 -> 1.124
--- ChangeLog 2006/07/28 18:18:39 1.123
+++ ChangeLog 2006/07/28 18:22:43 1.124
@@ -13,6 +13,9 @@
Changes between 1.4.2 and 1.5.0 (13-Mar-2006 to XX-May-2006)
+ o Fixed potential memory leak in uuid_create() as spotted by SPLINT.
+ [Ralf S. Engelschall]
+
o Cleanup source code according to complains by SPLINT.
[Ralf S. Engelschall]
|
|
ossp-pkg/uuid/uuid.c 1.59 -> 1.60
--- uuid.c 2006/05/11 09:37:28 1.59
+++ uuid.c 2006/07/28 18:22:43 1.60
@@ -105,13 +105,26 @@
if ((obj = (uuid_t *)malloc(sizeof(uuid_t))) == NULL)
return UUID_RC_MEM;
- /* create PRNG, MD5 and SHA1 sub-objects */
- if (prng_create(&obj->prng) != PRNG_RC_OK)
+ /* create PRNG sub-object */
+ if (prng_create(&obj->prng) != PRNG_RC_OK) {
+ free(obj);
return UUID_RC_INT;
- if (md5_create(&obj->md5) != MD5_RC_OK)
+ }
+
+ /* create MD5 sub-object */
+ if (md5_create(&obj->md5) != MD5_RC_OK) {
+ prng_destroy(obj->prng);
+ free(obj);
return UUID_RC_INT;
- if (sha1_create(&obj->sha1) != SHA1_RC_OK)
+ }
+
+ /* create SHA1 sub-object */
+ if (sha1_create(&obj->sha1) != SHA1_RC_OK) {
+ md5_destroy(obj->md5);
+ prng_destroy(obj->prng);
+ free(obj);
return UUID_RC_INT;
+ }
/* set UUID object initially to "Nil UUID" */
uuid_load(obj, "nil");
|
|