lib: util: asn1 tests. Check every asn1 return.
authorJeremy Allison <jra@samba.org>
Fri, 19 Sep 2014 19:46:49 +0000 (12:46 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 25 Sep 2014 22:51:16 +0000 (00:51 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
lib/util/tests/asn1_tests.c

index 93ffbad..2c68cb4 100644 (file)
@@ -321,6 +321,7 @@ static bool test_asn1_Integer(struct torture_context *tctx)
 {
        int i;
        TALLOC_CTX *mem_ctx;
+       bool ret = false;
 
        mem_ctx = talloc_new(tctx);
 
@@ -331,25 +332,28 @@ static bool test_asn1_Integer(struct torture_context *tctx)
 
                data = asn1_init(mem_ctx);
                if (!data) {
-                       return -1;
+                       goto err;
                }
 
-               asn1_write_Integer(data, integer_tests[i].value);
+               if (!asn1_write_Integer(data, integer_tests[i].value)) goto err;
 
                blob.data = data->data;
                blob.length = data->length;
                torture_assert_data_blob_equal(tctx, blob, integer_tests[i].blob, "asn1_write_Integer gave incorrect result");
 
-               asn1_load(data, blob);
+               if (!asn1_load(data, blob)) goto err;
                torture_assert(tctx, asn1_read_Integer(data, &val), "asn1_write_Integer output could not be read by asn1_read_Integer()");
 
                torture_assert_int_equal(tctx, val, integer_tests[i].value,
                        "readback of asn1_write_Integer output by asn1_read_Integer() failed");
        }
 
-       talloc_free(mem_ctx);
+       ret = true;
 
-       return true;
+  err:
+
+       talloc_free(mem_ctx);
+       return ret;
 }