Return-Path: X-Original-To: apmail-apr-bugs-archive@www.apache.org Delivered-To: apmail-apr-bugs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13B3510125 for ; Sat, 29 Mar 2014 02:26:37 +0000 (UTC) Received: (qmail 95553 invoked by uid 500); 29 Mar 2014 02:26:36 -0000 Delivered-To: apmail-apr-bugs-archive@apr.apache.org Received: (qmail 95519 invoked by uid 500); 29 Mar 2014 02:26:36 -0000 Mailing-List: contact bugs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@apr.apache.org Delivered-To: mailing list bugs@apr.apache.org Received: (qmail 95512 invoked by uid 99); 29 Mar 2014 02:26:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Mar 2014 02:26:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.115] (HELO eir.zones.apache.org) (140.211.11.115) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Mar 2014 02:26:34 +0000 Received: by eir.zones.apache.org (Postfix, from userid 80) id 5B4A51AAAB; Sat, 29 Mar 2014 02:26:14 +0000 (UTC) From: bugzilla@apache.org To: bugs@apr.apache.org Subject: [Bug 56330] New: APR_DBD_MYSQL.c error Date: Sat, 29 Mar 2014 02:26:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: APR X-Bugzilla-Component: APR-util X-Bugzilla-Version: 1.5.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: weiqiang_li@hotmail.com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: bugs@apr.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org https://issues.apache.org/bugzilla/show_bug.cgi?id=56330 Bug ID: 56330 Summary: APR_DBD_MYSQL.c error Product: APR Version: 1.5.3 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P2 Component: APR-util Assignee: bugs@apr.apache.org Reporter: weiqiang_li@hotmail.com There is a bug or a mixture in the file's *dbd_mysql_end_transaction* function: static int dbd_mysql_end_transaction(apr_dbd_transaction_t *trans) { int ret = -1; if (trans) { /* rollback on error or explicit rollback request */ if (trans->errnum || TXN_DO_ROLLBACK(trans)) { trans->errnum = 0; ret = mysql_rollback(trans->handle->conn); } else { ret = mysql_commit(trans->handle->conn); } } ret |= mysql_autocommit(trans->handle->conn, 1); trans->handle->trans = NULL; return ret; } This function was called only by *dbd_mysql_transaction* function: static int dbd_mysql_transaction(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_transaction_t **trans) { /* Don't try recursive transactions here */ if (handle->trans) { dbd_mysql_end_transaction(handle->trans) ; } if (!*trans) { *trans = apr_pcalloc(pool, sizeof(apr_dbd_transaction_t)); } (*trans)->errnum = mysql_autocommit(handle->conn, 0); (*trans)->handle = handle; handle->trans = *trans; return (*trans)->errnum; } As we can see, the trans is guaranteed to be not NULL when it called *dbd_mysql_end_transaction*, so it is no need to check it again in the function. What's mare, the check for trans value in *dbd_mysql_end_transaction* has no proper scope: it dereferences trans even though it is NULL(This will generate a segmentfault). -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org For additional commands, e-mail: bugs-help@apr.apache.org