[138940] trunk/base/src/pextlib1.0/Pextlib.c

raimue at macports.org raimue at macports.org
Fri Jul 24 04:06:48 PDT 2015


Revision: 138940
          https://trac.macports.org/changeset/138940
Author:   raimue at macports.org
Date:     2015-07-24 04:06:48 -0700 (Fri, 24 Jul 2015)
Log Message:
-----------
pextlib: Remove fixed buffer size by using vasprintf

Modified Paths:
--------------
    trunk/base/src/pextlib1.0/Pextlib.c

Modified: trunk/base/src/pextlib1.0/Pextlib.c
===================================================================
--- trunk/base/src/pextlib1.0/Pextlib.c	2015-07-24 10:26:49 UTC (rev 138939)
+++ trunk/base/src/pextlib1.0/Pextlib.c	2015-07-24 11:06:48 UTC (rev 138940)
@@ -107,9 +107,13 @@
 
 __printflike(3, 0)
 static void ui_message(Tcl_Interp *interp, const char *severity, const char *format, va_list va) {
-    char buf[1024], tclcmd[32];
+    char tclcmd[32];
+    char *buf;
 
-    vsnprintf(buf, sizeof(buf), format, va);
+    if (vasprintf(&buf, format, va) < 0) {
+        perror("vasprintf");
+        return;
+    }
 
     snprintf(tclcmd, sizeof(tclcmd), "ui_%s $warn", severity);
 
@@ -118,6 +122,7 @@
         fprintf(stderr, "Error evaluating tcl statement `%s': %s\n", tclcmd, Tcl_GetStringResult(interp));
     }
     Tcl_UnsetVar(interp, "warn", 0);
+    free(buf);
 }
 
 __printflike(2, 3)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20150724/6a6a3223/attachment.html>


More information about the macports-changes mailing list