You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2021/06/22 22:24:10 UTC

svn commit: r1890980 - /apr/apr/trunk/dbm/apr_dbm.c

Author: minfrin
Date: Tue Jun 22 22:24:10 2021
New Revision: 1890980

URL: http://svn.apache.org/viewvc?rev=1890980&view=rev
Log:
Use apr_psprintf() instead of apr_strerror() to avoid a worst case allocation.

Modified:
    apr/apr/trunk/dbm/apr_dbm.c

Modified: apr/apr/trunk/dbm/apr_dbm.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/dbm/apr_dbm.c?rev=1890980&r1=1890979&r2=1890980&view=diff
==============================================================================
--- apr/apr/trunk/dbm/apr_dbm.c (original)
+++ apr/apr/trunk/dbm/apr_dbm.c Tue Jun 22 22:24:10 2021
@@ -87,7 +87,7 @@ APR_DECLARE(apr_status_t) apr_dbm_get_dr
     }
 
     if (!type) {
-    	type = DBM_NAME;
+        type = DBM_NAME;
     }
 
     *vtable = NULL;
@@ -112,11 +112,10 @@ APR_DECLARE(apr_status_t) apr_dbm_get_dr
     }
 
     if (result && !*result) {
-        char *buffer = apr_pcalloc(pool, ERROR_SIZE);
         apu_err_t *err = apr_pcalloc(pool, sizeof(apu_err_t));
-        if (err && buffer) {
-            apr_strerror(APR_ENOTIMPL, buffer, ERROR_SIZE - 1);
-            err->msg = buffer;
+        if (err) {
+            apr_status_t rv = APR_ENOTIMPL;
+            err->msg = apr_psprintf(pool, "%pm", &rv);
             err->reason = apr_pstrdup(pool, type);
             *result = err;
         }
@@ -138,7 +137,7 @@ APR_DECLARE(apr_status_t) apr_dbm_get_dr
     }
 
     if (!type) {
-    	type = DBM_NAME;
+        type = DBM_NAME;
     }
 
     if (!strcasecmp(type, "default"))        type = DBM_NAME;