--- parser3/src/main/pa_exception.C 2020/10/14 21:20:15 1.55 +++ parser3/src/main/pa_exception.C 2026/10/18 21:05:35 1.65 @@ -1,8 +1,8 @@ /** @file Parser: exception class. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ #include "pa_common.h" @@ -10,7 +10,7 @@ #include "pa_sapi.h" #include "pa_globals.h" -volatile const char * IDENT_PA_EXCEPTION_C="$Id: pa_exception.C,v 1.55 2020/10/14 21:20:15 moko Exp $" IDENT_PA_EXCEPTION_H; +volatile const char * IDENT_PA_EXCEPTION_C="$Id: pa_exception.C,v 1.65 2026/10/18 21:05:35 moko Exp $" IDENT_PA_EXCEPTION_H; // methods @@ -33,23 +33,26 @@ Exception::Exception(const char* atype, ftype=atype; fproblem_source=aproblem_source ? new String(*aproblem_source) : 0; - if(comment_fmt) { + if(!comment_fmt) { + fcomment=0; + } else if (!strcmp(comment_fmt, "%s")) { // to avoid MAX_STRING limit + va_list args; + va_start(args, comment_fmt); + fcomment=va_arg(args, const char *); + fcomment=fcomment ? pa_strdup(fcomment) : 0; + va_end(args); + } else { char comment[MAX_STRING]; va_list args; va_start(args, comment_fmt); - fcomment=pa_strdup(comment, vsnprintf(comment, MAX_STRING, comment_fmt, args)); + fcomment=pa_strdup(comment, pa_vsnprintf(comment, MAX_STRING, comment_fmt, args)); va_end(args); - } else - fcomment=0; + } } void Exception::add_comment(const char* acomment) { - if(fcomment && acomment){ - char *comment=new(PointerFreeGC) char[strlen(fcomment) + strlen(acomment) + 1]; - strcpy(comment, fcomment); - strcat(comment, acomment); - fcomment=comment; - } + if(acomment) + fcomment=pa_strcat(fcomment, acomment); } const String* Exception::problem_source() const {