gnucash-htdocs master: Prevent null references in translations cache.

John Ralls jralls at code.gnucash.org
Fri Mar 31 22:46:57 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash-htdocs/commit/7afd5fdd (commit)
	from  https://github.com/Gnucash/gnucash-htdocs/commit/23f21d1f (commit)



commit 7afd5fdd499830f8f2775c7ba481c48aef20ccc7
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 31 19:45:46 2023 -0700

    Prevent null references in translations cache.

diff --git a/externals/gettext.php b/externals/gettext.php
index de50b8c..633df2b 100644
--- a/externals/gettext.php
+++ b/externals/gettext.php
@@ -159,11 +159,15 @@ class gettext_reader {
       $this->cache_translations = array ();
       /* read all strings in the cache */
       for ($i = 0; $i < $this->total; $i++) {
-        $this->STREAM->seekto($this->table_originals[$i * 2 + 2]);
-        $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]);
-        $this->STREAM->seekto($this->table_translations[$i * 2 + 2]);
-        $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]);
-        $this->cache_translations[$original] = $translation;
+          $offset = $i * 2 + 2;
+          if (!($this && $this->table_originals[$offset])) {
+              continue;
+          }
+          $this->STREAM->seekto($this->table_originals[$offset]);
+          $original = $this->STREAM->read($this->table_originals[$offset - 1]);
+          $this->STREAM->seekto($this->table_translations[$offset]);
+          $translation = $this->STREAM->read($this->table_translations[$offset - 1]);
+          $this->cache_translations[$original] = $translation;
       }
     }
   }



Summary of changes:
 externals/gettext.php | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)



More information about the gnucash-changes mailing list