|
|
commit be0f06e79116f8dae021be112963fdfac2fec74f
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Thu Nov 24 14:35:47 2022 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Thu Nov 24 14:35:47 2022 +0100
Remove two "warning: pointer xxx used after void* realloc()" messages
src/Fl_SVG_Image.cxx | 6 +++---
src/fl_draw.cxx | 11 ++++++-----
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git src/Fl_SVG_Image.cxx src/Fl_SVG_Image.cxx
index 7c8a6ff..ca52a55 100644
--- src/Fl_SVG_Image.cxx
+++ src/Fl_SVG_Image.cxx
@@ -119,9 +119,9 @@ static char *svg_inflate(gzFile gzf, // can be a file or the read end of a pipe
do {
if (is_compressed && p + size > out + out_size) {
out_size += size;
- char *tmp = (char*)realloc(out, out_size + 1);
- p = tmp + (p - out);
- out = tmp;
+ unsigned delta = (p - out);
+ out = (char*)realloc(out, out_size + 1);
+ p = out + delta;
}
if ( fdwrite >= 0 && Fl::system_driver()->write_nonblocking_fd(fdwrite, bytes, rest_bytes) ) {
free(out);
diff --git src/fl_draw.cxx src/fl_draw.cxx
index 468d032..d5395c3 100644
--- src/fl_draw.cxx
+++ src/fl_draw.cxx
@@ -79,11 +79,12 @@ static const char* expand_text_(const char* from, char*& buf, int maxbuf, double
if (o > e) {
if (maxbuf) break; // don't overflow buffer
l_local_buff += int(o - e) + 200; // enlarge buffer
- buf = (char*)realloc(local_buf, l_local_buff);
- e = buf + l_local_buff - 4; // update pointers to buffer content
- o = buf + (o - local_buf);
- word_end = buf + (word_end - local_buf);
- local_buf = buf;
+ unsigned delta_o = (o - local_buf);
+ unsigned delta_end = (word_end - local_buf);
+ local_buf = (char*)realloc(local_buf, l_local_buff);
+ e = local_buf + l_local_buff - 4; // update pointers to buffer content
+ o = local_buf + delta_o;
+ word_end = local_buf + delta_end;
}
if (c == '\t') {
[ Direct Link to Message ] | |
|
| |