[OpenWrt-Devel] [PATCH 1/4 v3] luci2: fix null pointer exception

Alexandru Ardelean ardeleanalex at gmail.com
Sat Nov 22 03:23:37 EST 2014


[quick idea/suggestion] What about just doing ? :

if (val == null)
   return;


On Sat, Nov 22, 2014 at 3:47 AM, Álvaro Fernández Rojas <noltari at gmail.com>
wrote:

> This fixes system/system not properly loading due to themes being null.
>
> Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
> ---
> v3: follow conventions as stated by rmilecki
> v2: fix broken validation
>
> diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js
> index 040f1e5..a2f10af 100644
> --- a/luci2/htdocs/luci2/luci2.js
> +++ b/luci2/htdocs/luci2/luci2.js
> @@ -5190,17 +5190,20 @@ function LuCI2()
>                         {
>                                 delete validation.message;
>
> -                               if ((val.length == 0 && !d.opt))
> -                               {
> -                                       rv = d.self.setError($elem,
> L.tr('Field must not be empty'));
> -                               }
> -                               else if (val.length > 0 &&
> !vstack[0].apply(val, vstack[1]))
> -                               {
> -                                       rv = d.self.setError($elem,
> validation.message, vstack[1]);
> -                               }
> -                               else
> -                               {
> -                                       rv = d.self.setError($elem);
> +                               if (val != null)
> +                               {
> +                                       if ((val.length == 0 && !d.opt))
> +                                       {
> +                                               rv =
> d.self.setError($elem, L.tr('Field must not be empty'));
> +                                       }
> +                                       else if (val.length > 0 &&
> !vstack[0].apply(val, vstack[1]))
> +                                       {
> +                                               rv =
> d.self.setError($elem, validation.message, vstack[1]);
> +                                       }
> +                                       else
> +                                       {
> +                                               rv =
> d.self.setError($elem);
> +                                       }
>                                 }
>                         }
>
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20141122/9b89d51f/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list