有漏洞的代码

String result =a;

JSONObject json = null;
try {
json = new JSONObject(result);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}


这样的代码有漏洞吗,有的,必须要判断result是否为空,


当然如果你直接捕捉catch  什么都不做  直接return null;也是可以的,


否则肯定有空指针错误

你可能感兴趣的:(Android开发)