Skip to content

Commit 4c95dea

Browse files
author
astrelsky
committed
Fixed crashes in fill out class action
1 parent 1fc879c commit 4c95dea

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/main/java/cppclassanalyzer/cmd/FillOutClassBackgroundCmd.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,18 @@ private void setMember(ClassTypeInfoDB member, int offset) {
186186
}
187187
comp = struct.getComponent(offset);
188188
}
189-
if (comp.getFieldName().startsWith("super_") && offset == 0) {
190-
return;
189+
if (comp != null && comp.getFieldName() != null) {
190+
if (comp.getFieldName().startsWith("super_") && offset == 0) {
191+
return;
192+
}
191193
}
192194
DataType memberDt = member.getClassDataType();
193195
String name = createMemberName(memberDt, struct, offset);
194-
struct.replaceAtOffset(offset, memberDt, memberDt.getLength(), name, null);
196+
if (offset > struct.getLength()) {
197+
struct.insertAtOffset(offset, memberDt, memberDt.getLength());
198+
} else {
199+
struct.replaceAtOffset(offset, memberDt, memberDt.getLength(), name, null);
200+
}
195201
}
196202

197203
private static String createMemberName(DataType dt, Structure struct, int offset) {

src/main/java/cppclassanalyzer/data/manager/ClassTypeInfoManagerDB.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -464,12 +464,12 @@ public ClassTypeInfoDB getType(Function fun) {
464464
if (fun.getParentNamespace().isGlobal()) {
465465
return null;
466466
}
467-
if (!(fun.getParentNamespace() instanceof GhidraClass)) {
468-
Msg.info(this, fun.getParentNamespace().getName(true)+" is not a class");
469-
return null;
470-
}
471467
GenericCallingConvention cc = fun.getSignature().getGenericCallingConvention();
472468
if (cc.equals(GenericCallingConvention.thiscall)) {
469+
if (!(fun.getParentNamespace() instanceof GhidraClass)) {
470+
Msg.info(this, fun.getParentNamespace().getName(true)+" is not a class");
471+
return null;
472+
}
473473
return getType((GhidraClass) fun.getParentNamespace());
474474
}
475475
return null;

0 commit comments

Comments
 (0)