diff options
author | David Robillard <d@drobilla.net> | 2024-10-06 18:25:33 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-10-11 19:58:12 -0400 |
commit | f447448aa3c6c944a27c29793b92f4d7fb5df432 (patch) | |
tree | 56ff2c07b5b58d15a672e9daa38ec10d2b5b3db0 /src/server/ingen_lv2.cpp | |
parent | ae5e9980aabba34a5e7fbf101b55200b8b127573 (diff) | |
download | ingen-f447448aa3c6c944a27c29793b92f4d7fb5df432.tar.gz ingen-f447448aa3c6c944a27c29793b92f4d7fb5df432.tar.bz2 ingen-f447448aa3c6c944a27c29793b92f4d7fb5df432.zip |
Handle realloc failure and avoid potential null pointer arithmetic
Diffstat (limited to 'src/server/ingen_lv2.cpp')
-rw-r--r-- | src/server/ingen_lv2.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 930f350d..76bdcb54 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -318,7 +318,13 @@ public: break; } - buf = realloc(buf, sizeof(LV2_Atom) + atom.size); + void* const new_buf = realloc(buf, sizeof(LV2_Atom) + atom.size); + if (!new_buf) { + _engine.log().rt_error("Failed to allocate for from-UI ring\n"); + break; + } + + buf = new_buf; memcpy(buf, &atom, sizeof(LV2_Atom)); if (!_from_ui.read(atom.size, |