Fixing some Coverity issues (#3261)
* Use signed long long for `src_readlen`, so we can check for -1
* Fixes Coverity defect 396947 and 356103
* Replace Unicode quotes with ASCII
* Ue signed structure in case -1 is returned (CID 396933)
* Need signed to check negative (CID 395560)
* Fix memleaks in `test_autocmplt_global`
* Related CIDs: 356309, 356307
* Set initial value of `ret` to false
This commit is contained in:
parent
d20f68d7ab
commit
61e8ace32a
3 changed files with 11 additions and 8 deletions
|
|
@ -111,7 +111,7 @@ RZ_IPI RzCmdStatus rz_cmd_shell_cp_handler(RzCore *core, int argc, const char **
|
|||
// cd
|
||||
RZ_IPI RzCmdStatus rz_cmd_shell_cd_handler(RzCore *core, int argc, const char **argv) {
|
||||
static char *olddir = NULL;
|
||||
bool ret = true;
|
||||
bool ret = false;
|
||||
const char *dir = "~";
|
||||
if (argc > 1) {
|
||||
dir = argv[1];
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ static const char *gzerr(int n) {
|
|||
* \param srcLen source bytes length
|
||||
* \param srcConsumed consumed source bytes length
|
||||
* \param dstLen uncompressed bytes length
|
||||
* \param wbits the size of the history buffer (or “window size”), and what header and trailer format is expected.
|
||||
* \param wbits the size of the history buffer (or "window size"), and what header and trailer format is expected.
|
||||
* \return ptr to uncompressed
|
||||
*/
|
||||
RZ_API ut8 *rz_inflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits) {
|
||||
|
|
@ -126,7 +126,7 @@ err_exit:
|
|||
* \param srcLen source bytes length
|
||||
* \param srcConsumed consumed source bytes length
|
||||
* \param dstLen compressed bytes length
|
||||
* \param wbits the size of the history buffer (or “window size”), and what header and trailer format is expected.
|
||||
* \param wbits the size of the history buffer (or "window size"), and what header and trailer format is expected.
|
||||
* \return ptr to compressed
|
||||
*/
|
||||
RZ_API ut8 *rz_deflatew(RZ_NONNULL const ut8 *src, int srcLen, int *srcConsumed, int *dstLen, int wbits) {
|
||||
|
|
@ -194,7 +194,7 @@ err_exit:
|
|||
* \param dst destination buffer
|
||||
* \param block_size block sizes to use while deflating data
|
||||
* \param src_consumed consumed source buffer length
|
||||
* \param wbits the size of the history buffer (or “window size”), and what header and trailer format is expected.
|
||||
* \param wbits the size of the history buffer (or "window size"), and what header and trailer format is expected.
|
||||
* \return true if successful; false otherwise
|
||||
*/
|
||||
RZ_API bool rz_deflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits) {
|
||||
|
|
@ -204,7 +204,7 @@ RZ_API bool rz_deflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst,
|
|||
int err = 0, flush = Z_NO_FLUSH;
|
||||
bool ret = true;
|
||||
ut64 dst_cursor = 0, src_cursor = 0;
|
||||
ut64 src_readlen = 0;
|
||||
st64 src_readlen = 0;
|
||||
z_stream stream;
|
||||
|
||||
memset(&stream, 0, sizeof(z_stream));
|
||||
|
|
@ -260,7 +260,7 @@ return_goto:
|
|||
* \param dst destination buffer
|
||||
* \param block_size block sizes to use while inflating data
|
||||
* \param src_consumed consumed source buffer length
|
||||
* \param wbits the size of the history buffer (or “window size”), and what header and trailer format is expected.
|
||||
* \param wbits the size of the history buffer (or "window size"), and what header and trailer format is expected.
|
||||
* \return true if successful; false otherwise
|
||||
*/
|
||||
RZ_API bool rz_inflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed, int wbits) {
|
||||
|
|
@ -270,7 +270,7 @@ RZ_API bool rz_inflatew_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst,
|
|||
int err = 0, flush = Z_NO_FLUSH;
|
||||
bool ret = true;
|
||||
ut64 src_cursor = 0;
|
||||
ut64 src_readlen = 0;
|
||||
st64 src_readlen = 0;
|
||||
z_stream stream;
|
||||
|
||||
memset(&stream, 0, sizeof(z_stream));
|
||||
|
|
@ -388,7 +388,7 @@ static bool lzma_action_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst,
|
|||
ut8 *inbuf = RZ_NEWS(ut8, block_size);
|
||||
ut8 *outbuf = RZ_NEWS(ut8, block_size);
|
||||
ut64 src_cursor = 0;
|
||||
ut64 src_readlen = 0;
|
||||
st64 src_readlen = 0;
|
||||
|
||||
strm.next_in = NULL;
|
||||
strm.avail_in = 0;
|
||||
|
|
|
|||
|
|
@ -439,6 +439,8 @@ static bool test_autocmplt_global(void) {
|
|||
mu_assert_notnull(parser, "create type parser");
|
||||
char *errmsg = NULL;
|
||||
RzType *typ = rz_type_parse_string_single(parser, "int", &errmsg);
|
||||
free(errmsg);
|
||||
|
||||
mu_assert_notnull(typ, "parsed type");
|
||||
rz_analysis_var_global_set_type(glob2, typ);
|
||||
|
||||
|
|
@ -457,6 +459,7 @@ static bool test_autocmplt_global(void) {
|
|||
mu_assert_streq(rz_pvector_at(&r->options, 1), "GCHR", "GCHR found");
|
||||
rz_line_ns_completion_result_free(r);
|
||||
|
||||
rz_type_parser_free(parser);
|
||||
rz_core_free(core);
|
||||
mu_end;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue