Jamling / SmartIM4IntelliJ

IntelliJ IDEA上的SmartIM(原SmartQQ)插件,可以在IDEA中使用QQ或微信聊天
Apache License 2.0
877 stars 98 forks source link

插件bug #26

Closed adminChina closed 6 years ago

adminChina commented 6 years ago

com.scienjus.smartqq.handler.FriendHandler 两处数组越界 反编译代码 1、 categoryMap.put(category.getIndex(), category); 2、 ((Category) categoryMap.get(item.get("categories").getAsInt())).addFriend(friend);

两处bug需要添加数组越界判断 1、 int index = category.getIndex(); if (index >= categoryMap.size()) { index = 0; } categoryMap.put(index, category);

2、 int index = item.get("categories").getAsInt(); if (index >= categoryMap.size()) { index = 0; } ((Category) categoryMap.get(index )).addFriend(friend);

Jamling commented 6 years ago

@adminChina 哥们,你竟然反编译了!源代码其实是公开的 😆 ,谢谢建议~

Jamling commented 6 years ago

Souce code:

        Map<Integer, Category> categoryMap = new TreeMap<>();
        JsonArray categories = result.getAsJsonArray("categories");

        categoryMap.put(0, Category.defaultCategory());

        for (int i = 0; categories != null && i < categories.size(); i++) {
            JsonObject item = categories.get(i).getAsJsonObject();
            Category category = handleCategory(item);
            categoryMap.put(category.getIndex(), category); // IndexOutOfBound?
        }

categoryMap是不限定大小的,应该不会IndexOutOfBound,如果你可以重现,请下载SmartIM代码,在smartqq模块中debug一下。

adminChina commented 6 years ago

g d nftms 8l45c 79 2

2017-12-15 13:00:31.011 [Thread-4] ERROR (LOG.java:37) - SmartQQ初始化失败 java.lang.NullPointerException: null at com.scienjus.smartqq.handler.FriendHandler.handleCategoryList(FriendHandler.java:95) at com.scienjus.smartqq.client.SmartQQClient.init(SmartQQClient.java:216) at cn.ieclipse.smartqq.QQContactView.doLoadContacts(QQContactView.java:103) at cn.ieclipse.smartim.views.IMContactView$1.run(IMContactView.java:70)

ax775 yzgaj sb7 c9u c

错误我贴出来了,这边categoryMap.size = 1 catId = 6 ,所以导致报错

Jamling commented 6 years ago

谢谢反馈~, 我从截图中看到,你的QQ分组好奇怪啊,竟然只有一个组(还不是默认组)。好友跟组根本不匹配。不知道你在PC QQ中手机QQ上是否正常。 不过,这确实是一个问题,腾讯的smartqq api竟然返回了不对称的好友与分组!

Jamling commented 6 years ago

已更新

            int catId = item.get("categories").getAsInt();
            Category category = categoryMap.get(catId);
            // fix https://github.com/Jamling/SmartQQ4IntelliJ/issues/26
            if (category == null) {
                category = Category.unknownCategory(catId);
                categoryMap.put(category.getIndex(), category);
            }
            category.addFriend(friend);
adminChina commented 6 years ago

我这边安装你的插件,登陆报错,而我同事却是正常使用,我以为是我的分组的问题,删除分组只留下一个(默认分组修改了名称),然后还是报错,后面我就反编译你的代码,发现你这边代码和我的分组对不上,就对你的代码做了修改 ,然后提出bug。

Jamling commented 6 years ago

@adminChina 那估计是腾讯后台缓存未同步更新导致的。smart qq腾讯也不维护,存在比较多的bug。你登录报错应该不是这个原因引起的。可能是别的原因。我已修改了smartqq 客户端代码,你看下,是否可以正常登录了。