GP-5822 Corrected errors related to null CommentType returned by

CommentFieldLocation
This commit is contained in:
ghidra1 2025-07-11 09:04:34 -04:00
parent 3ad921d5c7
commit 183ecf3acf
3 changed files with 13 additions and 4 deletions

View file

@ -758,9 +758,11 @@ public class CodeBrowserClipboardProvider extends ByteCopier
CommentFieldLocation commentFieldLocation = (CommentFieldLocation) currentLocation;
Address address = commentFieldLocation.getAddress();
CommentType commentType = commentFieldLocation.getCommentType();
if (commentType != null) {
SetCommentCmd cmd = new SetCommentCmd(address, commentType, string);
return tool.execute(cmd, currentProgram);
}
}
return false;
}

View file

@ -255,6 +255,9 @@ public class CommentsPlugin extends Plugin implements OptionsChangeListener {
CommentFieldLocation cfLoc = (CommentFieldLocation) loc;
CommentType type = cfLoc.getCommentType();
if (type == null) {
return;
}
switch (type) {
case PRE:
action.getPopupMenuData()

View file

@ -26,13 +26,17 @@ public class CommentTypeUtils {
* @param cu
* @param loc
* @param defaultCommentType
* @return comment type
* @return comment type or defaultCommentType if location does not correspond
* to a comment
*/
public static CommentType getCommentType(CodeUnit cu, ProgramLocation loc,
CommentType defaultCommentType) {
if (loc instanceof CommentFieldLocation) {
CommentFieldLocation cfLoc = (CommentFieldLocation) loc;
return cfLoc.getCommentType();
CommentType type = cfLoc.getCommentType();
if (type != null) {
return type;
}
}
else if (loc instanceof PlateFieldLocation) {
return CommentType.PLATE;