Skip to content

Commit

Permalink
fix: --help cause coredump
Browse files Browse the repository at this point in the history
  • Loading branch information
qgymib committed Dec 20, 2022
1 parent de2f0eb commit 8c09aca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Fixed
1. Fix: crash on log if no hook passed
2. Fix: `--help` cause coredump


## v1.0.1 (2022/04/29)
Expand Down
2 changes: 1 addition & 1 deletion include/cutest.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/**
* @brief Development version.
*/
#define CUTEST_VERSION_PREREL 5
#define CUTEST_VERSION_PREREL 6

#ifdef __cplusplus
extern "C" {
Expand Down
10 changes: 5 additions & 5 deletions src/cutest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,17 +1080,17 @@ typedef struct test_ctx

struct
{
FILE* f_out; /**< Output file */
int need_close; /**< Need close */
FILE* f_out; /**< Output file */
int need_close; /**< Need close */
}io;

const cutest_hook_t* hook;
}test_ctx_t;

typedef struct test_ctx2
{
char strbuf[256]; /**< String buffer */
jmp_buf jmpbuf; /**< Jump buffer */
char strbuf[512]; /**< String buffer */
jmp_buf jmpbuf; /**< Jump buffer */
}test_ctx2_t;

static int _test_on_cmp_case(const cutest_map_node_t* key1, const cutest_map_node_t* key2, void* arg)
Expand Down Expand Up @@ -2286,7 +2286,7 @@ static int _test_setup(int argc, char* argv[], const cutest_hook_t* hook)
_test_setup_arg_logfile(options.optarg);
break;
case help:
_print_encoded(g_test_ctx.io.f_out, s_test_help_encoded);
_print_encoded(_get_logfile(), s_test_help_encoded);
return -1;
default:
break;
Expand Down

0 comments on commit 8c09aca

Please sign in to comment.