[augeas-devel] [PATCH] asprintf glibc API fixes (transform.c)

James Antill james.antill at redhat.com
Wed May 21 18:28:08 UTC 2008


# HG changeset patch
# User james at code.and.org
# Date 1211394414 14400
# Node ID 507fcf7206ef85cb96d0907567e8482508193daf
# Parent  f5da8dfd12c5b2bc6c5b8c9c238a1051da2121f4
 Fix for the joy that is the glibc asprintf API.

diff --git a/src/transform.c b/src/transform.c
--- a/src/transform.c
+++ b/src/transform.c
@@ -387,12 +387,16 @@
     struct lns_error *err;
     int result = -1;
 
-    if (asprintf(&augorig, "%s%s", aug->root, filename) == -1)
+    if (asprintf(&augorig, "%s%s", aug->root, filename) == -1) {
+        augorig = NULL;
         goto done;
-
-    if (asprintf(&augnew, "%s%s" EXT_AUGNEW, aug->root, filename) == -1)
+    }
+    
+    if (asprintf(&augnew, "%s%s" EXT_AUGNEW, aug->root, filename) == -1) {
+        augnew = NULL;
         goto done;
-
+    }
+    
     if (access(augorig, R_OK) == 0) {
         text = read_file(augorig);
     } else {
@@ -429,8 +433,11 @@
         if (aug->flags & AUG_SAVE_BACKUP) {
             int r;
             r = asprintf(&augsave, "%s%s" EXT_AUGSAVE, aug->root, filename);
-            if (r == -1)
+            if (r == -1) {
+                augsave = NULL;
                 goto done;
+            }
+            
             if (rename(augorig, augsave) != 0) {
                 err_status = "rename_augsave";
                 goto done;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080521/e7e56258/attachment.sig>


More information about the augeas-devel mailing list