Module Name:    src
Committed By:   christos
Date:           Sun Aug 18 17:46:24 UTC 2024

Modified Files:
        src/lib/libintl: gettext.c

Log Message:
Avoid undefined behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/lib/libintl/gettext.c:1.33
--- src/lib/libintl/gettext.c:1.32	Fri Apr 12 22:01:38 2024
+++ src/lib/libintl/gettext.c	Sun Aug 18 13:46:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: gettext.c,v 1.32 2024/04/13 02:01:38 christos Exp $	*/
+/*	$NetBSD: gettext.c,v 1.33 2024/08/18 17:46:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 Citrus Project,
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: gettext.c,v 1.32 2024/04/13 02:01:38 christos Exp $");
+__RCSID("$NetBSD: gettext.c,v 1.33 2024/08/18 17:46:24 christos 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