Add a few safeties to the k5buf code, to make static analysis tools happier
authorGreg Hudson <ghudson@mit.edu>
Fri, 31 Oct 2008 18:35:28 +0000 (18:35 +0000)
committerGreg Hudson <ghudson@mit.edu>
Fri, 31 Oct 2008 18:35:28 +0000 (18:35 +0000)
ticket: 6200
status: open

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20943 dc483132-0cff-0310-8789-dd5450dbe970

src/util/support/k5buf.c

index 23fb2036583df5264f323943bd37abcfc737005d..974893d6ee24714e2eface4d7bb04c9beea7d79a 100644 (file)
@@ -72,8 +72,10 @@ static int ensure_space(struct k5buf *buf, size_t len)
     return 1;
 
  error_exit:
-    if (buf->buftype == DYNAMIC)
+    if (buf->buftype == DYNAMIC) {
         free(buf->data);
+        buf->data = NULL;
+    }
     buf->buftype = ERROR;
     return 0;
 }
@@ -206,4 +208,6 @@ void krb5int_free_buf(struct k5buf *buf)
         return;
     assert(buf->buftype == DYNAMIC);
     free(buf->data);
+    buf->data = NULL;
+    buf->buftype = ERROR;
 }