[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 0fd094f4765737c00f852
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: n0nb <n0...@us...> - 2025-05-23 02:20:42
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Hamlib -- Ham radio control libraries".
The branch, master has been updated
via 0fd094f4765737c00f852838c739c702a2e7376f (commit)
from 9570d9963b44a4ee2ad8d2a6befb982fd4dcb6fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0fd094f4765737c00f852838c739c702a2e7376f
Author: Mooneer Salem <mo...@gm...>
Date: Thu May 22 08:10:53 2025 -0700
Fix issue where Hamlib attempts to use memory returned by setlocale() after being freed.
diff --git a/include/num_stdio.h b/include/num_stdio.h
index 4ba063a95..f564f097a 100644
--- a/include/num_stdio.h
+++ b/include/num_stdio.h
@@ -23,6 +23,9 @@
#define _NUM_STDIO_H 1
#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
/*
* This header file is internal to Hamlib and its backends,
@@ -36,27 +39,42 @@
#define num_sscanf(a...) \
({ int __ret; char *__savedlocale; \
__savedlocale = setlocale(LC_NUMERIC, NULL); \
+ if (__savedlocale != NULL) { \
+ __savedlocale = strdup(__savedlocale); \
+ assert(__savedlocale != NULL); \
+ } \
setlocale(LC_NUMERIC, "C"); \
__ret = sscanf(a); \
setlocale(LC_NUMERIC, __savedlocale); \
+ if (__savedlocale != NULL) free(__savedlocale); \
__ret; \
})
#define num_sprintf(s, a...) \
({ int __ret; char *__savedlocale; \
__savedlocale = setlocale(LC_NUMERIC, NULL); \
+ if (__savedlocale != NULL) { \
+ __savedlocale = strdup(__savedlocale); \
+ assert(__savedlocale != NULL); \
+ } \
setlocale(LC_NUMERIC, "C"); \
__ret = sprintf(s, a); \
setlocale(LC_NUMERIC, __savedlocale); \
+ if (__savedlocale != NULL) free(__savedlocale); \
__ret; \
})
#define num_snprintf(s, n, a...) \
({ int __ret; char *__savedlocale; \
__savedlocale = setlocale(LC_NUMERIC, NULL); \
+ if (__savedlocale != NULL) { \
+ __savedlocale = strdup(__savedlocale); \
+ assert(__savedlocale != NULL); \
+ } \
setlocale(LC_NUMERIC, "C"); \
__ret = snprintf(s, n, a); \
setlocale(LC_NUMERIC, __savedlocale); \
+ if (__savedlocale != NULL) free(__savedlocale); \
__ret; \
})
-----------------------------------------------------------------------
Summary of changes:
include/num_stdio.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
hooks/post-receive
--
Hamlib -- Ham radio control libraries
|