GP-5626 Corrected Bookmerge merge NPE. Ensure that category and comment

are never null
This commit is contained in:
ghidra1 2025-04-29 11:18:10 -04:00
parent 1179fc10a0
commit 8802b2dab0
3 changed files with 41 additions and 31 deletions

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -79,7 +79,8 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
@Override
public String getCategory() {
return record.getString(BookmarkDBAdapter.CATEGORY_COL);
String category = record.getString(BookmarkDBAdapter.CATEGORY_COL);
return category != null ? category : ""; // NOTE: Old data may have stored null
}
public void setComment(String comment) {
@ -95,7 +96,8 @@ public class BookmarkDB extends DatabaseObject implements Bookmark {
@Override
public String getComment() {
return record.getString(BookmarkDBAdapter.COMMENT_COL);
String comment = record.getString(BookmarkDBAdapter.COMMENT_COL);
return comment != null ? comment : ""; // NOTE: Old data may have stored null
}
@Override

View file

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -206,6 +206,11 @@ public class BookmarkDBAdapterV3 extends BookmarkDBAdapter {
return null;
}
if (category == null)
category = "";
if (comment == null)
comment = "";
Table table = tables[typeID];
long nextId = table.getKey() + 1;
long id = ((long) typeID << TYPE_ID_OFFSET) | nextId;