On Mon, Jul 18, 2022 at 8:35 AM Ganesh Mali <ganeshmaliforama...@gmail.com> wrote:
> Recently we got ownership of a legacy piece of code with no knowledge > transfer and we cannot figure out why a certain line of code with > apr_dbd_pselect results in segmentation fault in the c code which is > deployed on Apache 2.4 using mysql on Amazon Linux2. The same piece of c > code works perfectly fine on Apache 2.2 and Centos with mysql same version. > Code in question is as follows. And the line throwing the seg fault is the > second call to apr_dbd_pselect (second last line in the code). > snip /* jdh -- table_name is not used can be used for prepared statement hash name */ > jstmt = apr_hash_get(dbd->prepared,table_name,APR_HASH_KEY_STRING); > if (NULL == jstmt) { > fprintf(stderr,"%s.%d Could not find prepared statement: > %s\n",__FILE__, __LINE__,table_name); fflush(stderr); > return ""; > } > > const char *arglist[2]; > arglist[0] = arg1; > > I recommend to init arglist[1] to NULL here. Cheers Nathan