Jelajahi Sumber

Fixed error handling in mn_decode()

Fixed two bugs that kept mn_decode from reporting any errors.
Jens Alfke 11 tahun lalu
induk
melakukan
3a6404573a
1 mengubah file dengan 5 tambahan dan 3 penghapusan
  1. 5 3
      mnemonic.c

+ 5 - 3
mnemonic.c

@@ -450,10 +450,12 @@ mn_decode (char *src, void *dest, int destsize)
 
   while ((index = mn_next_word_index (&src)) != 0)
     {
-      if (index == 0 && *src != 0)
-	return MN_EWORD;
       (void) mn_decode_word_index (index, dest, destsize, &offset);
     }
-  (void) mn_decode_word_index (MN_EOF, dest, destsize, &offset);
+  if (index == 0 && *src != 0)
+    return MN_EWORD;
+  int status = mn_decode_word_index (MN_EOF, dest, destsize, &offset);
+  if (status < 0)
+    return status;
   return offset;
 }