]> mj.ucw.cz Git - libucw.git/commitdiff
Trans: Duplicate exception ids to transaction pool.
authorPavel Charvat <pchar@ucw.cz>
Thu, 11 Nov 2021 10:42:49 +0000 (10:42 +0000)
committerPavel Charvat <pchar@ucw.cz>
Thu, 11 Nov 2021 10:45:59 +0000 (10:45 +0000)
Otherwise it breaks after longjmp if allocated on stack, for example in bthrow().

ucw/trans.c

index db8838372db0d8a2d7f3dd70944a840ce2cfffdc..8c39c15be0f8ff6174c5aa3c11da681957e1b77d 100644 (file)
@@ -2,6 +2,7 @@
  *     The UCW Library -- Transactions
  *
  *     (c) 2008--2011 Martin Mares <mj@ucw.cz>
+ *     (c) 2021 Pavel Charvat <pchar@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -201,7 +202,7 @@ trans_vthrow(const char *id, void *object, const char *fmt, va_list args)
   if (!mp)
     vdie(fmt, args);
   struct exception *x = mp_alloc(mp, sizeof(*x));
-  x->id = id;
+  x->id = mp_strdup(mp, id);
   x->object = object;
   x->msg = mp_vprintf(mp, fmt, args);
   trans_throw_exc(x);