Module Name:    src
Committed By:   martin
Date:           Sun Sep 15 10:58:53 UTC 2024

Modified Files:
        src/lib/libintl [netbsd-10]: gettext.c

Log Message:
Additionally pull up the following, requested by riastradh in ticket #842:

        lib/libintl/gettext.c   1.33

Avoid undefined behaviour.


To generate a diff of this commit:
cvs rdiff -u -r1.31.8.1 -r1.31.8.2 src/lib/libintl/gettext.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libintl/gettext.c
diff -u src/lib/libintl/gettext.c:1.31.8.1 src/lib/libintl/gettext.c:1.31.8.2
--- src/lib/libintl/gettext.c:1.31.8.1	Thu Sep 12 19:41:09 2024
+++ src/lib/libintl/gettext.c	Sun Sep 15 10:58:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gettext.c,v 1.31.8.1 2024/09/12 19:41:09 martin Exp $	*/
+/*	$NetBSD: gettext.c,v 1.31.8.2 2024/09/15 10:58:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 Citrus Project,
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: gettext.c,v 1.31.8.1 2024/09/12 19:41:09 martin Exp $");
+__RCSID("$NetBSD: gettext.c,v 1.31.8.2 2024/09/15 10:58:53 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -174,11 +174,13 @@ pgettext_impl(const char *domainname, co
 
 	translation = dcngettext(domainname, msgctxt_id,
 		msgid2, n, category);
-	free(msgctxt_id);
 
-	if (translation == msgctxt_id)
+	if (translation == msgctxt_id) {
+		free(msgctxt_id);
 		return msgid1;
+	}
 
+	free(msgctxt_id);
 	p = strchr(translation, '\004');
 	if (p)
 		return p + 1;

Reply via email to