Fix potential null problem.
[openssl.git] / crypto / aria / aria.c
index b59b4a44aa44bfc5a6bf0d8f67e73fff032123b4..293bcc72bd03bcb4d634fa2888e37bc938540aaa 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright (c) 2017, Oracle and/or its affiliates.  All rights reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * Public domain version is distributed above.
  */
 
-/* ====================================================================
- * Copyright (c) 2017 Oracle and/or its affiliates.  All rights reserved.
- */
-
 #include <openssl/e_os2.h>
 #include "internal/aria.h"
 
@@ -476,13 +473,13 @@ void aria_encrypt(const unsigned char *in, unsigned char *out,
 {
     register uint32_t reg0, reg1, reg2, reg3;
     int Nr;
-
-    const ARIA_u128 *rk = key->rd_key;
+    const ARIA_u128 *rk;
 
     if (in == NULL || out == NULL || key == NULL) {
         return;
     }
 
+    rk = key->rd_key;
     Nr = key->rounds;
 
     if (Nr != 12 && Nr != 14 && Nr != 16) {
@@ -545,7 +542,7 @@ int aria_set_encrypt_key(const unsigned char *userKey, const int bits,
     uint32_t w0[4], w1[4], w2[4], w3[4];
     const uint32_t *ck;
 
-    ARIA_u128 *rk = key->rd_key;
+    ARIA_u128 *rk;
     int Nr = (bits + 256) / 32;
 
     if (userKey == NULL || key == NULL) {
@@ -555,6 +552,7 @@ int aria_set_encrypt_key(const unsigned char *userKey, const int bits,
         return -2;
     }
 
+    rk = key->rd_key;
     key->rounds = Nr;
     ck = &Key_RC[(bits - 128) / 64][0];