Bug 586671 AffixMgr::parse_convtable leaks pattern/pattern2 if it can't create both. r=ryanvm, a=roc.
authortimeless@mozdev.org
Sun, 30 Jan 2011 12:45:04 +1300
changeset 61626 aacc3b418049d4547423c13aa0022f630161b537
parent 61625 8cfa767f666cec411c63b1025cc552e8487efa56
child 61627 336d5906cb0f7be789450241d9813f8412ebe360
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersryanvm, roc
bugs586671
milestone2.0b11pre
Bug 586671 AffixMgr::parse_convtable leaks pattern/pattern2 if it can't create both. r=ryanvm, a=roc.
extensions/spellcheck/hunspell/src/affixmgr.cpp
--- a/extensions/spellcheck/hunspell/src/affixmgr.cpp
+++ b/extensions/spellcheck/hunspell/src/affixmgr.cpp
@@ -3529,21 +3529,25 @@ int  AffixMgr::parse_convtable(char * li
                     break; 
                   }
                   default: break;
                }
                i++;
            }
            piece = mystrsep(&tp, 0);
         }
-        if (!pattern || !pattern2) {
-             HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum());
-             return 1;
-        }
-        (*rl)->add(pattern, pattern2);
+      if (!pattern || !pattern2) {
+         if (pattern)
+            free(pattern);
+         if (pattern2)
+            free(pattern2);
+         HUNSPELL_WARNING(stderr, "error: line %d: table is corrupt\n", af->getlinenum());
+         return 1;
+      }
+      (*rl)->add(pattern, pattern2);
    }
    return 0;
 }
 
 
 /* parse in the typical fault correcting table */
 int  AffixMgr::parse_phonetable(char * line, FileMgr * af)
 {