diff options
author | Ali Alzyod <ali198724@gmail.com> | 2020-06-22 16:54:51 +0900 |
---|---|---|
committer | WooHyun Jung <wh0705.jung@samsung.com> | 2020-06-22 16:54:51 +0900 |
commit | 1bbd03b7683dc6f163fff94130d017367178d0f1 (patch) | |
tree | c0b64db7608e6e9b92024b282a3fbba800c42f85 /src/lib/eina | |
parent | e3e3d0cfe4d753782d0adc81a68e5cd7ca27c5b9 (diff) | |
download | efl-1bbd03b7683dc6f163fff94130d017367178d0f1.tar.gz |
eina_strbuf: resolve segfault when replace used with read_only buffer
Summary: when eina_strbuf_replace is used by read_only buffer, this will cause segfault (access invalid memory)
Reviewers: cedric
Reviewed By: cedric
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Maniphest Tasks: T8757
Differential Revision: https://phab.enlightenment.org/D11989
Diffstat (limited to 'src/lib/eina')
-rw-r--r-- | src/lib/eina/eina_strbuf_common.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/eina/eina_strbuf_common.c b/src/lib/eina/eina_strbuf_common.c index e08d4b79fe..ebec119c2a 100644 --- a/src/lib/eina/eina_strbuf_common.c +++ b/src/lib/eina/eina_strbuf_common.c @@ -945,6 +945,10 @@ eina_strbuf_replace(Eina_Strbuf *buf, if (n) spos++; } + pos = spos - (const char *)buf->buf; + len1 = strlen(str); + len2 = strlen(with); + /* This is a read only buffer which need change to be made */ if (buf->ro) { @@ -956,9 +960,6 @@ eina_strbuf_replace(Eina_Strbuf *buf, buf->buf = dest; } - pos = spos - (const char *)buf->buf; - len1 = strlen(str); - len2 = strlen(with); if (len1 != len2) { /* resize the buffer if necessary */ |