Pretty: fix use of uninitialised variable

The string chunk getter doesn't set ptr if there was an error
decoding. Instead, we need to deal with the error first.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira
2019-03-05 19:59:25 -08:00
parent 587ff539ba
commit 49ef3f89ac
+3 -1
View File
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2018 Intel Corporation
** Copyright (C) 2019 Intel Corporation
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and associated documentation files (the "Software"), to deal
@@ -422,6 +422,8 @@ static CborError value_to_pretty(CborStreamFunction stream, void *out, CborValue
}
err = _cbor_value_get_string_chunk(it, &ptr, &n, it);
if (err)
return err;
if (!ptr)
break;