Browse Source

ncd: Fix crash with num_multiply(..., "0").

Ambroz Bizjak 11 years ago
parent
commit
f4500da972
1 changed files with 1 additions and 1 deletions
  1. 1 1
      ncd/modules/arithmetic.c

+ 1 - 1
ncd/modules/arithmetic.c

@@ -144,7 +144,7 @@ static int compute_subtract (NCDModuleInst *i, uintmax_t n1, uintmax_t n2, uintm
 
 
 static int compute_multiply (NCDModuleInst *i, uintmax_t n1, uintmax_t n2, uintmax_t *out)
 static int compute_multiply (NCDModuleInst *i, uintmax_t n1, uintmax_t n2, uintmax_t *out)
 {
 {
-    if (n1 > UINTMAX_MAX / n2) {
+    if (n2 != 0 && n1 > UINTMAX_MAX / n2) {
         ModuleLog(i, BLOG_ERROR, "multiplication overflow");
         ModuleLog(i, BLOG_ERROR, "multiplication overflow");
         return 0;
         return 0;
     }
     }