Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX some memory errors by valgrind #516

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defaults:
shell: bash

env:
OPENSSL_SRC_VERSION: 1.1.1o
OPENSSL_SRC_VERSION: 1.1.1w

jobs:
build:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
BUILD_WITH_OPENSSL_SRC: ${{ matrix.BUILD_WITH_OPENSSL_SRC }}
CXX: g++
run: |
sudo apt-get -qq install rake bison git gperf zlib1g-dev g++-11 libstdc++-11-dev
sudo apt-get -qq install rake bison git gperf zlib1g-dev g++-11 libstdc++-11-dev valgrind
sudo apt-get remove -y libssl-dev
if [ "$CXX" = "g++" ]; then
export CXX="g++-11" CC="gcc-11" LD="gcc-11"
Expand Down Expand Up @@ -78,6 +78,9 @@ jobs:
NGINX_VERSION: ${{ matrix.NGINX_VERSION }}
BUILD_DYNAMIC_MODULE: ${{ matrix.BUILD_DYNAMIC_MODULE }}
BUILD_WITH_OPENSSL_SRC: ${{ matrix.BUILD_WITH_OPENSSL_SRC }}
NUM_THREADS_ENV: 1
NGINX_RUNNER: valgrind
NGINX_HEATTIME: 10
run: |
echo "NGINX_SRC_MAJOR=$(echo $NGINX_VERSION | cut -d '.' -f 1)" > nginx_version
echo "NGINX_SRC_MINOR=$(echo $NGINX_VERSION | cut -d '.' -f 2)" >> nginx_version
Expand Down
1 change: 0 additions & 1 deletion src/http/ngx_http_mruby_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ static mrb_value ngx_mrb_redirect(mrb_state *mrb, mrb_value self)
r->headers_out.status = rc;
} else {
ngx_http_internal_redirect(r, &ns, &r->args);
ngx_http_finalize_request(r, NGX_DONE);
}

return self;
Expand Down
8 changes: 5 additions & 3 deletions src/http/ngx_http_mruby_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ static ngx_int_t ngx_http_mruby_shared_state_compile(ngx_conf_t *cf, ngx_mrb_sta
#ifdef NGX_MRUBY_IREP_DEBUG
code->ctx->dump_result = TRUE;
#endif

if (code->code_type == NGX_MRB_CODE_TYPE_FILE) {
if ((mrb_file = fopen((char *)code->code.file, "r")) == NULL) {
return NGX_ERROR;
Expand All @@ -1026,7 +1026,7 @@ static ngx_int_t ngx_http_mruby_shared_state_compile(ngx_conf_t *cf, ngx_mrb_sta

#ifdef NGX_MRUBY_IREP_DEBUG
/* mrb_codedump_all() is not declared in mruby headers. So just follows the mruby way. See mruby/src/load.c. */
void mrb_codedump_all(mrb_state*, struct RProc*);
void mrb_codedump_all(mrb_state *, struct RProc *);
mrb_codedump_all(state->mrb, code->proc);
#endif

Expand Down Expand Up @@ -2047,9 +2047,11 @@ static int ngx_http_mruby_ssl_cert_handler(ngx_ssl_conn_t *ssl_conn, void *data)
return 0;
}

host.len = 0;
host.data = NULL;
servername = SSL_get_servername(ssl_conn, TLSEXT_NAMETYPE_host_name);

if (servername == NULL) {
host.len = 0;
ngx_log_error(NGX_LOG_DEBUG, c->log, 0, MODULE_NAME " : mruby ssl handler: SSL server name NULL");
} else {
host.len = ngx_strlen(servername);
Expand Down