Remove two "warning: pointer xxx used after void* realloc()" messages

This commit is contained in:
ManoloFLTK
2022-11-24 14:35:47 +01:00
parent c1ba9f31ec
commit be0f06e791
2 changed files with 9 additions and 8 deletions
+3 -3
View File
@@ -119,9 +119,9 @@ static char *svg_inflate(gzFile gzf, // can be a file or the read end of a pipe
do { do {
if (is_compressed && p + size > out + out_size) { if (is_compressed && p + size > out + out_size) {
out_size += size; out_size += size;
char *tmp = (char*)realloc(out, out_size + 1); unsigned delta = (p - out);
p = tmp + (p - out); out = (char*)realloc(out, out_size + 1);
out = tmp; p = out + delta;
} }
if ( fdwrite >= 0 && Fl::system_driver()->write_nonblocking_fd(fdwrite, bytes, rest_bytes) ) { if ( fdwrite >= 0 && Fl::system_driver()->write_nonblocking_fd(fdwrite, bytes, rest_bytes) ) {
free(out); free(out);
+6 -5
View File
@@ -79,11 +79,12 @@ static const char* expand_text_(const char* from, char*& buf, int maxbuf, double
if (o > e) { if (o > e) {
if (maxbuf) break; // don't overflow buffer if (maxbuf) break; // don't overflow buffer
l_local_buff += int(o - e) + 200; // enlarge buffer l_local_buff += int(o - e) + 200; // enlarge buffer
buf = (char*)realloc(local_buf, l_local_buff); unsigned delta_o = (o - local_buf);
e = buf + l_local_buff - 4; // update pointers to buffer content unsigned delta_end = (word_end - local_buf);
o = buf + (o - local_buf); local_buf = (char*)realloc(local_buf, l_local_buff);
word_end = buf + (word_end - local_buf); e = local_buf + l_local_buff - 4; // update pointers to buffer content
local_buf = buf; o = local_buf + delta_o;
word_end = local_buf + delta_end;
} }
if (c == '\t') { if (c == '\t') {