Gitweb links:
...log
http://git.netsurf-browser.org/librufl.git/shortlog/c0106f315e738db6fcb9cbbb34453fd0774b6926
...commit
http://git.netsurf-browser.org/librufl.git/commit/c0106f315e738db6fcb9cbbb34453fd0774b6926
...tree
http://git.netsurf-browser.org/librufl.git/tree/c0106f315e738db6fcb9cbbb34453fd0774b6926
The branch, master has been updated
via c0106f315e738db6fcb9cbbb34453fd0774b6926 (commit)
via 073ef37579203300b029dc19118a62030196a353 (commit)
via a4d7fddf88421a5e173ca9c814085a841e163924 (commit)
via 6909e9f3fb8a2163b259d20284e9cf656d00f72a (commit)
from d49a815620d8c9d9f0ab4f93661f2552d721de4c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=c0106f315e738db6fcb9cbbb34453fd0774b6926
commit c0106f315e738db6fcb9cbbb34453fd0774b6926
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
rufl_paint: initialise offset and check error first
If any of the process* functions return an error, that should
take precedence over any other decision (as the output values in
the error case are indeterminate).
Additionally, certain compilers fail to identify that there is
no path in which offset cannot be initialised when needed. Help
them along by initialising it to an invalid value first.
diff --git a/src/rufl_paint.c b/src/rufl_paint.c
index 9dc0e3f..22e8427 100644
--- a/src/rufl_paint.c
+++ b/src/rufl_paint.c
@@ -257,6 +257,7 @@ rufl_code rufl_process(rufl_action action,
if (length == 0 && font1 == font0)
offset_map[n] = string - string0;
+ offset = n;
if (font0 == NOT_AVAILABLE)
code = rufl_process_not_available(action, s, n,
font_size, &x, y, flags,
@@ -270,11 +271,12 @@ rufl_code rufl_process(rufl_action action,
font_size, slant, &x, y, flags,
click_x, &offset, callback, context);
+ if (code != rufl_OK)
+ return code;
+
if ((action == rufl_X_TO_OFFSET || action == rufl_SPLIT) &&
(offset < n || click_x < x))
break;
- if (code != rufl_OK)
- return code;
} while (!(length == 0 && font1 == font0));
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=073ef37579203300b029dc19118a62030196a353
commit 073ef37579203300b029dc19118a62030196a353
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
rufl_decompose: avoid pointer arithmetic
The buffer end pointer returned from xfont_switch_output_to_buffer
in the case where it was previously invoked with the magic value
8 is not a pointer at all, but the size of the required buffer
(including the initial 8 bytes). Cast it to a uintptr_t, rather
than performing bogus arithmetic involving NULL.
diff --git a/src/rufl_decompose.c b/src/rufl_decompose.c
index 2085e8f..de8fcab 100644
--- a/src/rufl_decompose.c
+++ b/src/rufl_decompose.c
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <inttypes.h>
#include <stdio.h>
#include <oslib/font.h>
@@ -71,7 +72,7 @@ rufl_code rufl_decompose_glyph(const char *font_family,
struct rufl_decomp_funcs *funcs, void *user)
{
int *buf, *p, *ep;
- int buf_size;
+ uintptr_t buf_size;
char *buf_end;
rufl_code err;
@@ -100,12 +101,13 @@ rufl_code rufl_decompose_glyph(const char *font_family,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
- buf_size = buf_end - (char *)NULL;
+ buf_size = (uintptr_t) buf_end;
/* Allocate and initialise buffer */
buf = malloc(buf_size);
if (!buf) {
- LOG("Failed to allocate decompose buffer of size %i", buf_size);
+ LOG("Failed to allocate decompose buffer of size %" PRIuPTR,
+ buf_size);
return rufl_OUT_OF_MEMORY;
}
buf[0] = 0;
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=a4d7fddf88421a5e173ca9c814085a841e163924
commit a4d7fddf88421a5e173ca9c814085a841e163924
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
rufl_substitution_table: reverse calloc parameters
The allocated size is the same but modern compilers care about
the order the parameters are provided in.
diff --git a/src/rufl_substitution_table.c b/src/rufl_substitution_table.c
index 9230ed7..f9df18e 100644
--- a/src/rufl_substitution_table.c
+++ b/src/rufl_substitution_table.c
@@ -780,7 +780,7 @@ static rufl_code direct(uint64_t *table, size_t
table_entries,
size_t blocks_needed, table_size;
unsigned int i, block;
- subst_table = calloc(sizeof(*subst_table), 1);
+ subst_table = calloc(1, sizeof(*subst_table));
if (!subst_table)
return rufl_OUT_OF_MEMORY;
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=6909e9f3fb8a2163b259d20284e9cf656d00f72a
commit 6909e9f3fb8a2163b259d20284e9cf656d00f72a
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
rufl_substitution_table: avoid spurious use-after-free warning
This could never happen as a) range is guaranteed to be positive
(it's the next power of 2 up from table_entries, which is also
guaranteed to be positive) and b) if the realloc failed, the block
pointed at by t64 is, by definition, still valid.
However, given at least one version of GCC is confused, rework the
logic to only update the substitution table pointer if the result
of the realloc is non-NULL (the pointer is already pointing at the
old block address (i.e. t64) beforehand).
diff --git a/src/rufl_substitution_table.c b/src/rufl_substitution_table.c
index 0bdf78d..9230ed7 100644
--- a/src/rufl_substitution_table.c
+++ b/src/rufl_substitution_table.c
@@ -505,10 +505,9 @@ static rufl_code create_substitution_table_chd(uint64_t
*table,
/* Shrink the table to its final size. If this fails, leave
* the existing data intact as it's correct -- we just have
* twice the storage usage we need. */
- subst_table->table = realloc(t64,
- range * sizeof(*subst_table->table));
- if (!subst_table->table)
- subst_table->table = (uint32_t *) t64;
+ table = realloc(t64, range * sizeof(*subst_table->table));
+ if (table)
+ subst_table->table = (uint32_t *) table;
*substitution_table = &subst_table->base;
-----------------------------------------------------------------------
Summary of changes:
src/rufl_decompose.c | 8 +++++---
src/rufl_paint.c | 6 ++++--
src/rufl_substitution_table.c | 9 ++++-----
3 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/rufl_decompose.c b/src/rufl_decompose.c
index 2085e8f..de8fcab 100644
--- a/src/rufl_decompose.c
+++ b/src/rufl_decompose.c
@@ -6,6 +6,7 @@
*/
#include <assert.h>
+#include <inttypes.h>
#include <stdio.h>
#include <oslib/font.h>
@@ -71,7 +72,7 @@ rufl_code rufl_decompose_glyph(const char *font_family,
struct rufl_decomp_funcs *funcs, void *user)
{
int *buf, *p, *ep;
- int buf_size;
+ uintptr_t buf_size;
char *buf_end;
rufl_code err;
@@ -100,12 +101,13 @@ rufl_code rufl_decompose_glyph(const char *font_family,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
- buf_size = buf_end - (char *)NULL;
+ buf_size = (uintptr_t) buf_end;
/* Allocate and initialise buffer */
buf = malloc(buf_size);
if (!buf) {
- LOG("Failed to allocate decompose buffer of size %i", buf_size);
+ LOG("Failed to allocate decompose buffer of size %" PRIuPTR,
+ buf_size);
return rufl_OUT_OF_MEMORY;
}
buf[0] = 0;
diff --git a/src/rufl_paint.c b/src/rufl_paint.c
index 9dc0e3f..22e8427 100644
--- a/src/rufl_paint.c
+++ b/src/rufl_paint.c
@@ -257,6 +257,7 @@ rufl_code rufl_process(rufl_action action,
if (length == 0 && font1 == font0)
offset_map[n] = string - string0;
+ offset = n;
if (font0 == NOT_AVAILABLE)
code = rufl_process_not_available(action, s, n,
font_size, &x, y, flags,
@@ -270,11 +271,12 @@ rufl_code rufl_process(rufl_action action,
font_size, slant, &x, y, flags,
click_x, &offset, callback, context);
+ if (code != rufl_OK)
+ return code;
+
if ((action == rufl_X_TO_OFFSET || action == rufl_SPLIT) &&
(offset < n || click_x < x))
break;
- if (code != rufl_OK)
- return code;
} while (!(length == 0 && font1 == font0));
diff --git a/src/rufl_substitution_table.c b/src/rufl_substitution_table.c
index 0bdf78d..f9df18e 100644
--- a/src/rufl_substitution_table.c
+++ b/src/rufl_substitution_table.c
@@ -505,10 +505,9 @@ static rufl_code create_substitution_table_chd(uint64_t
*table,
/* Shrink the table to its final size. If this fails, leave
* the existing data intact as it's correct -- we just have
* twice the storage usage we need. */
- subst_table->table = realloc(t64,
- range * sizeof(*subst_table->table));
- if (!subst_table->table)
- subst_table->table = (uint32_t *) t64;
+ table = realloc(t64, range * sizeof(*subst_table->table));
+ if (table)
+ subst_table->table = (uint32_t *) table;
*substitution_table = &subst_table->base;
@@ -781,7 +780,7 @@ static rufl_code direct(uint64_t *table, size_t
table_entries,
size_t blocks_needed, table_size;
unsigned int i, block;
- subst_table = calloc(sizeof(*subst_table), 1);
+ subst_table = calloc(1, sizeof(*subst_table));
if (!subst_table)
return rufl_OUT_OF_MEMORY;
--
RISC OS Unicode Font Library