summaryrefslogtreecommitdiff
path: root/src/irmd/reg/reg.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2024-02-19 12:54:07 +0100
committerSander Vrijders <[email protected]>2024-02-19 14:09:38 +0100
commit52f4d6f7b72de7308b4200b5c4b6c3ccddf617a3 (patch)
tree98cb622e91bbc20cc9e76dd90ef28dfa656c41f7 /src/irmd/reg/reg.c
parenta23b29ea4c1bd9d0407b2b070eb2dc9ad15e71cc (diff)
downloadouroboros-52f4d6f7b72de7308b4200b5c4b6c3ccddf617a3.tar.gz
ouroboros-52f4d6f7b72de7308b4200b5c4b6c3ccddf617a3.zip
irmd: Fix free of uninitialized ptr
The reg_list_ipcps function left *ipcps uninitialized when there were no IPCPs in the system. This caused a free to SEGV in the IRMd when trying to allocate a flow. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/irmd/reg/reg.c')
-rw-r--r--src/irmd/reg/reg.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/irmd/reg/reg.c b/src/irmd/reg/reg.c
index 29d2a7ba..f486c1cc 100644
--- a/src/irmd/reg/reg.c
+++ b/src/irmd/reg/reg.c
@@ -911,8 +911,10 @@ int reg_list_ipcps(ipcp_list_msg_t *** ipcps)
pthread_mutex_lock(&reg.mtx);
- if (reg.n_ipcps == 0)
+ if (reg.n_ipcps == 0) {
+ *ipcps = NULL;
goto finish;
+ }
*ipcps = malloc(reg.n_ipcps * sizeof(**ipcps));
if (*ipcps == NULL) {
@@ -2158,4 +2160,3 @@ int reg_respond_ipcp(const struct ipcp_info * info)
pthread_mutex_unlock(&reg.mtx);
return -EIPCP;
}
-